Skip to content

Fix year precision for duration and elapsed formats - #368

Merged
liuliu-dev merged 2 commits into
github:mainfrom
Pybsama:codex/fix-year-precision
Jul 30, 2026
Merged

Fix year precision for duration and elapsed formats#368
liuliu-dev merged 2 commits into
github:mainfrom
Pybsama:codex/fix-year-precision

Conversation

@Pybsama

@Pybsama Pybsama commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

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

@liuliu-dev liuliu-dev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the fix! ❤️

@liuliu-dev
liuliu-dev merged commit 3433371 into github:main Jul 30, 2026
1 check 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.

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

2 participants