Created
August 16, 2021 09:59
-
-
Save KEIII/51a3f2ae975c0e04bc5c757ed1245624 to your computer and use it in GitHub Desktop.
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
/** | |
* @link https://bugs.chromium.org/p/v8/issues/detail?id=3547 | |
* @link https://github.com/nodejs/node/issues/33306 | |
*/ | |
const oldTimezoneOffsetFix = (d: Date): number => { | |
const ms = d.getTime(); | |
if (isNaN(ms)) return 0; | |
const utc = new Date(d.toISOString().slice(0, -1)).getTime(); | |
const offset = d.getTimezoneOffset() * 60_000; | |
return ms - utc + offset; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment