Skip to content

Commit a06ae77

Browse files
committed
Add DST adjust
1 parent c4318e9 commit a06ae77

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

dist/easycoder.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2905,10 +2905,19 @@ const EasyCoder_Core = {
29052905
content: ``
29062906
};
29072907
case `now`:
2908+
function isDST(d) {
2909+
let jan = new Date(d.getFullYear(), 0, 1).getTimezoneOffset();
2910+
let jul = new Date(d.getFullYear(), 6, 1).getTimezoneOffset();
2911+
return Math.max(jan, jul) !== d.getTimezoneOffset();
2912+
}
2913+
let now = Math.floor(Date.now() / 1000)
2914+
if (isDST(now)) {
2915+
now += 3600
2916+
}
29082917
return {
29092918
type: `constant`,
29102919
numeric: true,
2911-
content: Math.floor(Date.now() / 1000)
2920+
content: now
29122921
};
29132922
case `millisecond`:
29142923
return {

js/easycoder/Core.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2905,10 +2905,19 @@ const EasyCoder_Core = {
29052905
content: ``
29062906
};
29072907
case `now`:
2908+
function isDST(d) {
2909+
let jan = new Date(d.getFullYear(), 0, 1).getTimezoneOffset();
2910+
let jul = new Date(d.getFullYear(), 6, 1).getTimezoneOffset();
2911+
return Math.max(jan, jul) !== d.getTimezoneOffset();
2912+
}
2913+
let now = Math.floor(Date.now() / 1000)
2914+
if (isDST(now)) {
2915+
now += 3600
2916+
}
29082917
return {
29092918
type: `constant`,
29102919
numeric: true,
2911-
content: Math.floor(Date.now() / 1000)
2920+
content: now
29122921
};
29132922
case `millisecond`:
29142923
return {

0 commit comments

Comments
 (0)