Repository navigation
fix(time-rounding): round exact halves up with the nearest method - #874
Merged
evilguy4000 merged 1 commit intoNov 12, 2026
Merged
Conversation
round() rounds .5 to the even integer, so at 30-minute rounding a 15-minute entry was stored as 0 and a 75-minute entry as 60, while 45 became 60.
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.
With the "nearest" rounding method, an entry that lands exactly on a half interval rounds to the even multiple, because
round()in Python rounds .5 to even:A 15-minute task disappears and 75 minutes bills the same as 45. Same with 10 and 60 minute intervals (5 -> 0, 15 -> 20, 25 -> 20). With whole-minute entries these halves are common.
round_time_durationnow usesmath.floor(x + 0.5), so halves always round up, as the existing90m->nearest-60m=120mcase expects. Up, down and boundary are unchanged.Added
15m->nearest-30m=30mand150m->nearest-60m=180mtotest_time_rounding_param.py; both fail before the change. The rounding, manual-entry, user-settings and time-entry tests pass (113 + 47). Checked through the app models as well: 15, 45 and 75 minute entries are stored as 30, 60 and 90.