Skip to content

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.

@troyciesco
Copy link
Contributor

@niranjan-uma-shankar just noting i haven't forgotten about this - finishing up a couple other projects currently, then i'll be able to give more careful attention to the group of timezone PRs here and in the main repo so everything gets updated smoothly 👍

@niranjan-uma-shankar
Copy link
Author

@troyciesco Just circling back on this one. If you get a moment to share feedback, happy to make any further adjustments, if needed.

.sort((a, b) => a.offsetMinutes - b.offsetMinutes);
};

export default timezoneData;
Copy link
Contributor

Choose a reason for hiding this comment

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

@niranjan-uma-shankar thanks for your patience, I finally have a bit of bandwidth to look at this again!

One thought: is there any reason we couldn't export the result of timezoneDataWithGMTOffset as the default?

I haven't manually tested it, but think that might mean we wouldn't need TryGhost/Ghost#24557 anymore, and if @tryghost/timezone-data is imported in any other repos anywhere the labels will still look as expected without needing to import timezoneDataWithGMTOffset instead of timezoneData.

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