Skip to content

Add thorough tests for time zone transitions#3295

Open
ptomato wants to merge 1 commit intomainfrom
exhaustive-time-zone-testing
Open

Add thorough tests for time zone transitions#3295
ptomato wants to merge 1 commit intomainfrom
exhaustive-time-zone-testing

Conversation

@ptomato
Copy link
Collaborator

@ptomato ptomato commented Mar 10, 2026

This adds test/thorough/timezones.mjs which tests certain invariants for time zone transitions in every supported time zone. (It doesn't use snapshots, because those might have to be updated when the IANA database updates.)

For every time zone, it takes the first five transitions after 1850 (which was about when time zones started being used) and the last two transitions before 2000 (which should cover one spring-forward and one fall-back transition in zones that use DST), and for each of those seven transitions, tests

  • That each disambiguation value has the expected effect
  • That .with({ offset }) works to switch between the two repeated times in a fall-back transition

This covers many different sizes of UTC offset shift, from 24 hours down to 4 seconds, with the most common being -1 hour and +1 hour.

See: #556, tc39/test262#3002

@ptomato ptomato requested review from Ms2ger and justingrant March 10, 2026 02:34
@ptomato ptomato added the run snapshot tests Add this label to a PR if you want the snapshot tests to run on it. label Mar 10, 2026
@ptomato
Copy link
Collaborator Author

ptomato commented Mar 10, 2026

@justingrant Can you think of any more time zone invariants that should be tested here?

@codecov
Copy link

codecov bot commented Mar 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.83%. Comparing base (17d7ff1) to head (5e301d0).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3295   +/-   ##
=======================================
  Coverage   97.83%   97.83%           
=======================================
  Files          22       22           
  Lines       10725    10725           
  Branches     1856     1856           
=======================================
  Hits        10493    10493           
  Misses        215      215           
  Partials       17       17           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This adds test/thorough/timezones.mjs which tests certain invariants for
time zone transitions in every supported time zone. (It doesn't use
snapshots, because those might have to be updated when the IANA database
updates.)

For every time zone, it takes the first five transitions after 1850
(which was about when time zones started being used) and the last two
transitions before 2000 (which should cover one spring-forward and one
fall-back transition in zones that use DST), and for each of those seven
transitions, tests
- That each `disambiguation` value has the expected effect
- That .with({ offset }) works to switch between the two repeated times
  in a fall-back transition

This covers many different sizes of UTC offset shift, from 24 hours down
to 4 seconds, with the most common being -1 hour and +1 hour.

See: #556, tc39/test262#3002
@ptomato ptomato force-pushed the exhaustive-time-zone-testing branch from a9b6568 to 5e301d0 Compare March 10, 2026 02:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run snapshot tests Add this label to a PR if you want the snapshot tests to run on it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant