Fixed issue with price graph in relation to entering or leaving DST

This commit is contained in:
Gunnar Skjold
2023-03-25 19:14:21 +01:00
parent 938f9f69d1
commit dbd6205cca
7 changed files with 48 additions and 50 deletions

File diff suppressed because one or more lines are too long

View File

@@ -180,4 +180,9 @@ export function fmtnum(v,d) {
if(isNaN(d))
d = v < 10 ? 1 : 0;
return v.toFixed(d);
}
export function addHours(date, hours) {
date.setTime(date.getTime() + hours * 3600000);
return date;
}

View File

@@ -1,5 +1,5 @@
<script>
import { zeropad } from './Helpers.js';
import { zeropad, addHours } from './Helpers.js';
import BarChart from './BarChart.svelte';
export let json;
@@ -19,7 +19,6 @@
let points = [];
let cur = new Date();
for(i = hour; i<24; i++) {
cur.setUTCHours(i);
val = json[zeropad(h++)];
if(val == null) break;
xTicks.push({
@@ -34,9 +33,9 @@
});
min = Math.min(min, val*100);
max = Math.max(max, val*100);
addHours(cur, 1);
};
for(i = 0; i < 24; i++) {
cur.setUTCHours(i);
val = json[zeropad(h++)];
if(val == null) break;
xTicks.push({
@@ -51,6 +50,7 @@
});
min = Math.min(min, val*100);
max = Math.max(max, val*100);
addHours(cur, 1);
};
max = Math.ceil(max);