Created
March 27, 2023 20:39
-
-
Save megasmack/734455e0f6cfd0bcaf5cf71ab90c9d74 to your computer and use it in GitHub Desktop.
Daylight Savings JavaScript Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const stdTimezoneOffset = (date) => { | |
const jan = new Date(date.getFullYear(), 0, 1); | |
const jul = new Date(date.getFullYear(), 6, 1); | |
return Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset()); | |
}; | |
const isDstObserved = (date) => date.getTimezoneOffset() < stdTimezoneOffset(date); | |
const offset = start.getTimezoneOffset(); | |
const start = new Date(start.getTime() - (offset*60*1000)); | |
console.log('isDstObserved(start)', isDstObserved(start)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment