Skip to content

Commit fbcc1c2

Browse files
authored
rewrite DST handling (#1072)
1 parent 1c3000c commit fbcc1c2

File tree

9 files changed

+1697
-259
lines changed

9 files changed

+1697
-259
lines changed

demos/months.html

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,32 @@
1010
<body>
1111
<script src="../dist/uPlot.iife.js"></script>
1212
<script>
13-
let yrs = [2017,2018,2019];
1413
let mos = 'Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec'.split(",");
1514

16-
let ts = [];
15+
function dataFor(yrs) {
16+
let ts = [];
1717

18-
yrs.forEach(y => {
19-
mos.forEach(m => {
20-
// ts.push(Date.parse('11 ' + m + ' ' + y + ' 17:30:00 UTC')/1000);
21-
// ts.push(Date.parse('01 ' + m + ' ' + y + ' 23:30:00 UTC')/1000);
22-
ts.push(Date.parse('01 ' + m + ' ' + y + ' 00:00:00 UTC')/1000);
23-
})
24-
});
18+
yrs.forEach(y => {
19+
mos.forEach(m => {
20+
// ts.push(Date.parse('11 ' + m + ' ' + y + ' 17:30:00 UTC')/1000);
21+
// ts.push(Date.parse('01 ' + m + ' ' + y + ' 23:30:00 UTC')/1000);
22+
ts.push(Date.parse('01 ' + m + ' ' + y + ' 00:00:00 UTC')/1000);
23+
})
24+
});
2525

26-
let vals = [0,1,2,3,4,5,6,7,8,9,10];
26+
let vals = [0,1,2,3,4,5,6,7,8,9,10];
2727

28-
let data = [
29-
ts,
30-
ts.map((t, i) => i == 0 ? 5 : vals[Math.floor(Math.random() * vals.length)]),
31-
];
28+
let data = [
29+
ts,
30+
ts.map((t, i) => i == 0 ? 5 : vals[Math.floor(Math.random() * vals.length)]),
31+
];
32+
33+
return data;
34+
}
3235

3336
const opts = {
3437
width: 1920,
35-
height: 600,
38+
height: 200,
3639
title: "Months",
3740
tzDate: ts => uPlot.tzDate(new Date(ts * 1e3), 'Etc/UTC'),
3841
series: [
@@ -54,7 +57,8 @@
5457
],
5558
};
5659

57-
let u = new uPlot(opts, data, document.body);
60+
let u = new uPlot({...opts, title: 'No leap year'}, dataFor([2017,2018,2019]), document.body);
61+
let u2 = new uPlot({...opts, title: '2024 leap year'}, dataFor([2024,2025,2026]), document.body);
5862
</script>
5963
</body>
6064
</html>

0 commit comments

Comments
 (0)