Skip to content

Instantly share code, notes, and snippets.

@KEIII
Created August 16, 2021 09:59
Show Gist options
  • Save KEIII/51a3f2ae975c0e04bc5c757ed1245624 to your computer and use it in GitHub Desktop.
Save KEIII/51a3f2ae975c0e04bc5c757ed1245624 to your computer and use it in GitHub Desktop.
/**
* @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