Skip to content

Feat: Add formatDuration - #348

Merged
jlukic merged 2 commits into
mainfrom
feat/format-duration
Aug 26, 2026
Merged

Feat: Add formatDuration#348
jlukic merged 2 commits into
mainfrom
feat/format-duration

Conversation

@jlukic

@jlukic jlukic commented Aug 26, 2026

Copy link
Copy Markdown
Member

The inverse of toDuration. A config reads '5m' on the way in and can now show '5m' on the way out instead of 300000. One grammar in both directions, so everything it prints reads back.

Changes

  • formatDuration prints milliseconds in the largest unit filled (300000'5m', 90000'1.5m', 500'500ms')
  • lossless picks the largest unit that reads back exactly (100000'100s', where the default rounds to '1.7m')
  • unit holds one unit down a column, decimals is a maximum, separator gives '1.5 minutes'
  • The unit ladder is spelled in toDuration's vocabulary and editable via formatDuration.config.units

Risk

1/10 — new export, toDuration untouched. 295 B brotli over toDuration.

@jlukic
jlukic merged commit f113438 into main Aug 26, 2026
4 checks passed
@jlukic
jlukic deleted the feat/format-duration branch August 26, 2026 22:41
@github-actions github-actions Bot added Tests Modifies tests Utils Modifies utilities package Docs Modifies documentation labels Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Docs Modifies documentation Tests Modifies tests Utils Modifies utilities package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant