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. |
[Medium impact] The change reaches time-zone labels in date formatting and schedule summaries. The timezone fix appears sound, but the added comment must meet the repository's explicit rules before merging. Findings
Summary
Reviews (1) · Last reviewed commit: "fix(utils): pick the timezone abbreviati..." · Reviewed by Greptile |
| // Compare the zone's UTC offsets across the year: `format()` always | ||
| // includes the calendar date, so comparing formatted strings reported | ||
| // "DST observed" for the whole year and then "daylight" for every date. |
There was a problem hiding this comment.
Comment records change history
The new comment recounts the previous bug, but CLAUDE.md says change history belongs in commit messages. Keep the explanation that format() includes the calendar date and remove the account of the old behavior. This repository requirement must be satisfied before merging.
| // Compare the zone's UTC offsets across the year: `format()` always | |
| // includes the calendar date, so comparing formatted strings reported | |
| // "DST observed" for the whole year and then "daylight" for every date. | |
| // Compare UTC offsets because `format()` also includes the calendar date. |
Context Used: CLAUDE.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
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.