Skip to content

fix: Duration precision beyond 104 days, @stylistic 6, and 4.7.2 - #154

Merged
knowledgecode merged 4 commits into
masterfrom
develop
Nov 15, 2026
Merged

knowledgecode merged 4 commits into
masterfrom
develop

Conversation

@knowledgecode

Copy link
Copy Markdown
Owner

Summary

  • Fix Duration sub-millisecond parts for long durations: scaling the whole value to nanoseconds exceeded Number.MAX_SAFE_INTEGER after about 104 days, so toParts() and format() could return wrong milliseconds and smaller units even for integer values such as epoch timestamps. The fraction is now split off before decomposition. Docs describe how precision falls off for long durations.
  • Style: replace array-bracket-spacing, object-curly-spacing, and object-curly-newline with @stylistic/list-style, and put each item of multi-line option literals on its own line.
  • Chore: update devDependencies (including @stylistic/eslint-plugin 6) and bump the version to 4.7.2.

Test plan

  • npm run lint (no warnings) / npm run ts
  • npm test (73 files / 2359 tests)
  • npm run build && npx vitest run tests/build
  • npm run docs:build

…tyle

@stylistic/eslint-plugin 6 provides list-style, which covers the spacing
that array-bracket-spacing and object-curly-spacing enforced and also
requires one item per line in multi-line lists. Keep brackets tight and
braces padded on a single line, leave parentheses and type parameters
alone, and put each option of the multi-line Intl.DateTimeFormat and
default-parts literals on its own line.
…anoseconds

Scaling the whole duration to nanoseconds exceeded Number.MAX_SAFE_INTEGER
after about 104 days, so toParts() and format() could return wrong
milliseconds and smaller units even for integer durations such as epoch
timestamps. Split off the fraction, which subtracts out of a double
exactly, and decompose whole milliseconds and the nanosecond remainder
separately.

Switch the existing tests to fractions that are exact in binary, add
cases beyond the safe-integer range, and document how precision falls
off for long durations.
@codecov

codecov Bot commented Nov 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.88%. Comparing base (35014dd) to head (2bc6b08).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #154   +/-   ##
=======================================
  Coverage   98.87%   98.88%           
=======================================
  Files          77       77           
  Lines        1246     1250    +4     
  Branches      367      368    +1     
=======================================
+ Hits         1232     1236    +4     
  Partials       14       14           

☔ View full report in Codecov by Harness.
📢 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.

@knowledgecode
knowledgecode merged commit 0b9fb15 into master Nov 15, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant