aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-07-12 02:05:52 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2020-07-12 02:05:52 +0200
commitb7d73271decf51e2a0302e127c88f28531674288 (patch)
treea28276112d1394ce5a081dac6d1fb63df7649a66
parentFix graphical event overflow. (diff)
downloadcalp-b7d73271decf51e2a0302e127c88f28531674288.tar.gz
calp-b7d73271decf51e2a0302e127c88f28531674288.tar.xz
Created events dt{start,end} now correct date.
-rw-r--r--static/script.js18
1 files changed, 14 insertions, 4 deletions
diff --git a/static/script.js b/static/script.js
index ea1b057d..220451d9 100644
--- a/static/script.js
+++ b/static/script.js
@@ -20,10 +20,17 @@ function parents_until (element, obj) {
}
}
-function decimal_time_to_date (time) {
+function decimal_time_to_date (time, date) {
let hour = Math.floor(time);
let minute = (time - hour) * 60;
- return new Date(0,0,0,hour,minute,0);
+ if (date) {
+ return new Date(date.getFullYear(),
+ date.getMonth(),
+ date.getDate(),
+ hour, minute, 0);
+ } else {
+ return new Date(0,0,0,hour,minute,0);
+ }
}
let gensym_counter = 0;
@@ -103,10 +110,13 @@ function create_event_move (e) {
.25);
time1 = event.dataset.time1;
+ let date = new Date(event.dataset.date)
event.properties.dtstart =
- decimal_time_to_date(Math.min(Number(time1), Number(time2)));
+ decimal_time_to_date(Math.min(Number(time1), Number(time2)),
+ date);
event.properties.dtend =
- decimal_time_to_date(Math.max(Number(time1), Number(time2)));
+ decimal_time_to_date(Math.max(Number(time1), Number(time2)),
+ date);
}
function create_event_finisher (callback) {