Repository navigation
fix(timer): round duration before splitting off minutes - #14246
Merged
Merged
Conversation
`__timer_format_duration` split the duration into whole minutes and then rounded the remaining seconds to `TIMER_PRECISION`, so durations just under a minute boundary were shown as `60.0s` or `1m60.0s` instead of `1m0.0s` or `2m0.0s`. Round the whole duration to the displayed precision first and split it afterwards. Co-Authored-By: Claude Opus 5.5 <[email protected]>
robbyrussell
approved these changes
Nov 6, 2026
robbyrussell
left a comment
Member
There was a problem hiding this comment.
Thanks for your first contribution to Oh My Zsh! The tests pass on macOS with zsh 5.9, and times near a minute boundary now print correctly (1m0.0s instead of 60.0s). Merging.
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.
Standards checklist:
Changes:
__timer_format_durationsplit off the minutes before rounding the seconds, so a duration just under a minute boundary was displayed as60.0s, and longer ones as e.g.1m60.0s. The duration is now rounded to the displayed precision first (as an integer count of precision units) and only then split into minutes and seconds, so59.97displays as1m0.0sand119.97as2m0.0s.plugins/timer/tests/timer.test.zshcovering the boundary cases at precision 0, 1 and 2.Other comments:
AI disclosure: this change was prepared with AI assistance (Claude Code). I reviewed the diff and ran the tests myself.
Testing:
zsh -df plugins/timer/tests/timer.test.zsh— with the old implementation 6 of the 14 cases fail (the60.0s/1m60.0sones), with this change all 14 pass.