Skip to content

Instantly share code, notes, and snippets.

@sunpietro
Created March 14, 2022 08:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sunpietro/8f289aca5e1378018ca77f7d9b4bc85e to your computer and use it in GitHub Desktop.
Save sunpietro/8f289aca5e1378018ca77f7d9b4bc85e to your computer and use it in GitHub Desktop.
Detecting time zone offset change in DST
const calculateDSTDiff = (timezone) => {
const januaryOffset = moment.tz({ month: 0, day: 1 }, timezone).utcOffset();
const juneOffset = moment.tz({ month: 5, day: 1 }, timezone).utcOffset();
return Math.abs(juneOffset - januaryOffset);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment