Skip to content

Polyfill: Fix detection of bounding window start#3319

Merged
Ms2ger merged 3 commits into
mainfrom
3316-fix
May 21, 2026
Merged

Polyfill: Fix detection of bounding window start#3319
Ms2ger merged 3 commits into
mainfrom
3316-fix

Conversation

@ptomato
Copy link
Copy Markdown
Collaborator

@ptomato ptomato commented May 19, 2026

Seems to be a regression from #3147. There is a condition triggering the special case for avoiding a disambiguation when calculating the startEpochNs of the bounding window (added to fix #3149). This condition is not correct when largestUnit ≠ smallestUnit, and the smallest unit is 0 while a larger unit is nonzero. The condition only checks that the smallest unit (r1) is 0, while it should check that all larger units are 0 as well.

Updates the newly added snapshot tests to show where the differences in output are.

This fix corresponds to a needs-consensus PR that reached TC39 consensus in the meeting of 2026-05-19.

Closes: #3316

ptomato added 3 commits May 19, 2026 10:02
This adds thorough snapshotting tests for various types' since() and
until() methods with various combinations of largestUnit, smallestUnit,
and roundingIncrement.

At one point I tried adding these before, but the snapshot files were
too large for GitHub. But, it's worth trying again since we did actually
find bugs in these methods. I've done some tricks to reduce the snapshot
file size and cut down the testing space.

Note there is no datetimedifferencerounding.mjs - that snapshot file is
still too large. But I believe the code paths are sufficiently covered
by PlainDate and PlainTime.
This adds thorough snapshotting tests for Duration.round() with various
combinations of largestUnit, smallestUnit, and roundingIncrement, with a
relativeTo. But only a "boring" relativeTo, either 1970-01-01 in plain
or zoned (UTC) form.

At one point I tried to write a more comprehensive version of this
snapshot test using all the "interesting" values for relativeTo, but
the snapshot file was too large for GitHub. But, it's worth trying
again with this reduced testing space since we did actually find bugs
in these methods.
Seems to be a regression from
#3147. There is a
condition triggering the special case for avoiding a disambiguation
when calculating the startEpochNs of the bounding window (added to fix
#3149). This condition
is not correct when largestUnit ≠ smallestUnit, and the smallest unit
is 0 while a larger unit is nonzero. The condition only checks that the
smallest unit (r1) is 0, while it should check that all larger units
are 0 as well.

Updates the newly added snapshot tests to show where the differences in
output are.

See: #3316
@ptomato ptomato added the run snapshot tests Add this label to a PR if you want the snapshot tests to run on it. label May 19, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.39%. Comparing base (4df4199) to head (a704da3).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3319   +/-   ##
=======================================
  Coverage   98.39%   98.39%           
=======================================
  Files          22       22           
  Lines       10763    10763           
  Branches     1866     1866           
=======================================
  Hits        10590    10590           
  Misses        161      161           
  Partials       12       12           

☔ 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.

Copy link
Copy Markdown
Collaborator

@Ms2ger Ms2ger left a comment

Choose a reason for hiding this comment

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

Thanks!

@Ms2ger Ms2ger merged commit 7083e8c into main May 21, 2026
11 checks passed
@Ms2ger Ms2ger deleted the 3316-fix branch May 21, 2026 08:17
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

2 participants