Skip to content

Fix year precision for duration and elapsed formats - #368

Open
Pybsama wants to merge 2 commits into
github:mainfrom
Pybsama:codex/fix-year-precision
Open

Fix year precision for duration and elapsed formats#368
Pybsama wants to merge 2 commits into
github:mainfrom
Pybsama:codex/fix-year-precision

Conversation

@Pybsama

@Pybsama Pybsama commented Jul 29, 2026

Copy link
Copy Markdown

Summary

  • honor precision="year" when calculating elapsed durations
  • preserve the existing empty-duration result for an unknown runtime precision
  • cover positive and negative helper results plus rendered duration and elapsed output

Root cause

unitNames.indexOf("year") returns 0, but the logical-or expression treated
that valid index as falsy and replaced it with unitNames.length. Using the raw
index keeps 0 as the year cutoff and also preserves the existing -1
behavior for an unknown runtime value.

Testing

  • npm test (634 passing)
  • npm run lint
  • npm run build

Fixes #366

@Pybsama
Pybsama marked this pull request as ready for review July 29, 2026 05:56
@Pybsama
Pybsama requested a review from a team as a code owner July 29, 2026 05:56
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.

precision="year" on duration/elapsed format is ignored — falls back to full millisecond precision

1 participant