Fixed clock skew on graphs around midnight

This commit is contained in:
Gunnar Skjold 2023-07-02 14:51:57 +02:00
parent 4f90954084
commit c462b3bb00
4 changed files with 16 additions and 16 deletions

File diff suppressed because one or more lines are too long

View File

@ -9,7 +9,7 @@
$:{
showFull = Math.abs(new Date().getTime()-timestamp.getTime()) < 300000;
if(!isNaN(offset))
addHours(timestamp, offset - (timestamp.getHours() - timestamp.getUTCHours()));
addHours(timestamp, offset - ((timestamp.getHours() - timestamp.getUTCHours())%24));
}
</script>

View File

@ -17,7 +17,7 @@
min = max = 0;
let cur = addHours(new Date(), -24);
let currentHour = new Date().getUTCHours();
addHours(cur, sysinfo.clock_offset);
addHours(cur, sysinfo.clock_offset - ((cur.getHours() - cur.getUTCHours())%24));
for(i = currentHour; i<24; i++) {
let imp = json["i"+zeropad(i)];
let exp = json["e"+zeropad(i)];
@ -25,7 +25,7 @@
if(exp === undefined) exp = 0;
xTicks.push({
label: zeropad(cur.getUTCHours())
label: zeropad(cur.getHours())
});
points.push({
label: imp.toFixed(1),
@ -47,7 +47,7 @@
if(exp === undefined) exp = 0;
xTicks.push({
label: zeropad(cur.getUTCHours())
label: zeropad(cur.getHours())
});
points.push({
label: imp.toFixed(1),

View File

@ -17,8 +17,8 @@
min = max = 0;
let cur = new Date();
let lm = new Date();
addHours(cur, sysinfo.clock_offset);
addHours(lm, sysinfo.clock_offset);
addHours(cur, sysinfo.clock_offset - ((cur.getHours() - cur.getUTCHours())%24));
addHours(lm, sysinfo.clock_offset - ((lm.getHours() - lm.getUTCHours())%24));
lm.setDate(0);
for(i = cur.getDate(); i<=lm.getDate(); i++) {