Repository navigation
Conversation
…he formatted date getTimezoneAbbreviation compared Intl.DateTimeFormat#format() results of two dates in the same year. The formatted string always contains the calendar date, so the comparison reported "DST is observed" for every zone and then "the target date is daylight time" for every date: Los Angeles in January came out as PDT, London as BST, Sydney in July as AEDT. Compare the zone's UTC offsets at the two ends of the year instead. A zone whose offsets match does not observe DST; otherwise the smaller offset is standard time and any larger offset on the target date is daylight time, which covers both hemispheres.
|
@laoyyu is attempting to deploy a commit to the Sim Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
[Medium impact] The PR appears safe to merge, with no outstanding findings. Summary
Reviews (2) · Last reviewed commit: "chore(utils): keep the offset comparison..." · Reviewed by Greptile |
CLAUDE.md keeps change history in commit messages, so the comment only states why the offsets are compared instead of recounting the previous behaviour. Signed-off-by: laoyyu <laoyyu@foxmail.com>
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
getTimezoneAbbreviationdecides between the standard and daylight label by comparing formatted strings:format()also renders the calendar date, which always differs between two dates, so for every zone in the mapisDSTObservedwastrueandisDSTwastruetoo — the daylight label was returned all year:Fix
Compare the zone's UTC offsets at the two ends of the year instead of formatted strings (
getOffsetMinutes, derived fromIntl.formatToParts, sinceDatehas no timezone-aware offset accessor):How it was checked
packages/utils/src/formatting.test.tsgains four cases: winter/summer for northern zones, the inverted seasons forAustralia/Sydney, and zones without DST (Asia/Tokyo,Asia/Singapore).tsc --noEmit --skipLibCheckon the patched file passes.Fixes #9831. Prepared with an AI coding assistant; I reviewed the diff and ran the checks above.