Skip to content

Fix: Timezone dropdown label does not account for DST #584

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

niranjan-uma-shankar
Copy link

@niranjan-uma-shankar niranjan-uma-shankar commented Jul 29, 2025

Fixes TryGhost/Ghost#24559. The Admin facing changes are implemented in TryGhost/Ghost#24557, and needs to be deployed along with this PR.

Changes:

  • Remove the hardcoded GMT offsets in the label.
  • The timezoneDataWithGMTOffset() function dynamically prepends the GMT offset to the label, thereby ensuring that it respects DST.
  • Timezone data, after factoring in DST, is sorted by GMT offset to ensure that the dropdown values are intuitive.
  • TS config updated to use es2020 which is supported by modern browsers and allows us to use formatter.formatToParts().

This implements a GMT offset string that is DST aware, and is prepended to the label value.
…s supported by most modern browsers, so should be safe.
@niranjan-uma-shankar niranjan-uma-shankar changed the title Fix: GMT offset in timezone label is not DST aware Fix: Timezone dropdown label does not account for DST Jul 30, 2025
@niranjan-uma-shankar niranjan-uma-shankar marked this pull request as ready for review July 30, 2025 06:31
Uses longOffset to simplify the regex match and code.
Copy link
Contributor

@troyciesco troyciesco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@niranjan-uma-shankar before I dig too deep into this - could you add some tests for the new functions? Thanks!

};

const labelWithGMTOffset = (label: string, offsetString: string): string => {
return '(' + offsetString + ') ' + label;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could use a template literal here to stay consistent with L308

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, I've updated with this change.

@niranjan-uma-shankar
Copy link
Author

could you add some tests for the new functions

@troyciesco I've added tests now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Timezone dropdown shows static GMT offsets, not accounting for DST
2 participants