Repository navigation
fix: compare Temporal durations without relative dates - #119
Merged
43081j merged 2 commits intoNov 5, 2026
Merged
Conversation
Compare years, months and weeks as calendar components, then normalize remaining day/time fields exactly without choosing a reference date. Preserve day/time equivalence and nanosecond differences lost by total(). Cover calendar durations, negative values, precision boundaries, nested collections, constructor independence and input immutability. Document the calendar-independent equality rule. Signed-off-by: Mayank Dhingra <mayankdhingra02@gmail.com>
The agent went too far, this simplifies it.
43081j
force-pushed
the
fix-temporal-duration-comparison
branch
from
November 5, 2026 11:39
d43dcee to
aa9ae56
Compare
43081j
approved these changes
Nov 5, 2026
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.
Comparing two valid
Temporal.Duration.from('P1M')values currently throws becausetotal('nanoseconds')needs a reference date for years, months and weeks. Large day/time durations can also compare equal after a one-nanosecond difference is rounded away in the numeric total.Compare years, months and weeks separately, then normalize the remaining day/time fields to exact seconds and subsecond components. This supplies no arbitrary calendar or date: one month stays distinct from 30 days, while the existing equivalence of one day and 24 hours is preserved. It uses instance methods and does not depend on a global
Temporalor an instance'sconstructorproperty.Added 14 regression/control cases and documented the duration equality rule. Follow-up to the Temporal support in #88 and #104.
Validation:
npm teston configured Node 25.9.0 and current Node 26.12.1: lint, 201 Node tests, 199 Chrome tests and 2 existing browser skips on each.The existing Istanbul command collects no ESM coverage, also reproduced on unchanged main. Node 12 imports the library successfully, but the locked Temporal polyfill itself fails to parse there; Temporal compatibility checks pass from Node 14 onward. Tests ran locally on macOS; Linux remains for CI.