fix(timer): carry rounded minutes into the hour in humanDuration - #447
Merged
ralyodio merged 1 commit intoAug 29, 2026
Merged
Conversation
humanDuration derived hours and minutes independently from the raw seconds, so a sub-hour remainder that rounds up to 60 minutes printed as "60m", "1h 60m" or "23h 60m" instead of carrying into the hour it belongs in. Any tracked stretch in the last 30 seconds of an hour (e.g. 1h59m59s) rendered wrong in /timer off, /timer status and /timer log totals. Round to whole minutes first, then split into hours and minutes so the carry happens once. Add regression cases for the boundary.
Merged
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.
What
humanDuration()insrc/timer.mjsderives hours and minutes independently from the raw seconds:When the sub-hour remainder is in the last 30 seconds of a minute-that-completes-the-hour,
mrounds up to60whilehhas not been incremented, so the output shows60m,1h 60mor23h 60minstead of carrying into the hour.Reproduce (before)
This is user-facing in
/timer off,/timer statusand/timer logtotals — a time-tracking surface that renders e.g. 1h59m59s as "1h 60m".Fix
Round to whole minutes first, then split once so the carry happens in one place:
Tests
Added regression cases in
test/timer.test.mjs(3599→1h, 3570→1h, 3569→59m, 7199→2h, 86399→24h). Reverting only thesrc/timer.mjschange fails exactly that one test; with the fix all timer tests pass. Full suite: 2277 pass / 0 fail / 337 skip.