Skip to content

Commit

Permalink
Fixed date skew when computer is on different timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
gskjold committed Aug 3, 2024
1 parent 8adb705 commit de63263
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
12 changes: 6 additions & 6 deletions lib/SvelteUi/app/dist/index.js

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions lib/SvelteUi/app/src/lib/DayPlot.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@
let xTicks = [];
let points = [];
min = max = 0;
let cur = addHours(new Date(), -24);
let currentHour = new Date().getUTCHours();
addHours(cur, sysinfo.clock_offset - ((24 + cur.getHours() - cur.getUTCHours())%24));
let cur = new Date();
let lm = new Date();
lm.setDate(0);
lm.setHours(12);
let clock_adjust = ((lm.getHours() - lm.getUTCHours())%24) - sysinfo.clock_offset;
let currentHour = cur.getUTCHours();
addHours(cur, -clock_adjust-24);
for(i = currentHour; i<24; i++) {
let imp = json["i"+zeropad(i)];
let exp = json["e"+zeropad(i)];
Expand Down
6 changes: 4 additions & 2 deletions lib/SvelteUi/app/src/lib/MonthPlot.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
min = max = 0;
let cur = new Date();
let lm = new Date();
let clock_adjust = sysinfo.clock_offset - ((24 + cur.getHours() - cur.getUTCHours())%24);
lm.setDate(0);
lm.setHours(12);
let clock_adjust = ((lm.getHours() - lm.getUTCHours())%24) - sysinfo.clock_offset;
addHours(cur, -clock_adjust);
addHours(lm, -clock_adjust);
lm.setDate(0);
for(i = cur.getDate(); i<=lm.getDate(); i++) {
let imp = json["i"+zeropad(i)];
Expand Down

0 comments on commit de63263

Please sign in to comment.