Skip to content

fix(time-rounding): round exact halves up with the nearest method - #874

Merged
evilguy4000 merged 1 commit into
DRYTRIX:developfrom
jayhemnani9910:fix/nearest-rounding-half-up
Nov 12, 2026
Merged

evilguy4000 merged 1 commit into
DRYTRIX:developfrom
jayhemnani9910:fix/nearest-rounding-half-up

Conversation

@jayhemnani9910

Copy link
Copy Markdown
Contributor

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:

30-minute nearest rounding
15 min entry -> stored 0 min
45 min entry -> stored 60 min
75 min entry -> stored 60 min

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_duration now uses math.floor(x + 0.5), so halves always round up, as the existing 90m->nearest-60m=120m case expects. Up, down and boundary are unchanged.

Added 15m->nearest-30m=30m and 150m->nearest-60m=180m to test_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.

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.
@jayhemnani9910
jayhemnani9910 changed the base branch from main to develop November 12, 2026 08:53
@evilguy4000
evilguy4000 merged commit c5e5cc7 into DRYTRIX:develop Nov 12, 2026
17 of 19 checks 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.

2 participants