feat(time): accept H:MM input in the Log Time hours field (PMS-314) #164
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/PMS-314-time-hhmm-input"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Implements PMS-314.
What
The "Hours" field on both the Log Time (create) and Edit Time Entry forms now accepts clock-style
H:MMinput (e.g.0:30= 30 min,1:30= 90 min) alongside decimal hours (2.5). The field was an<input type="number">(PMS-233 added decimals), which blocks the colon, soH:MMcould never be typed. PMS-265 already addedH:MMas a display option; this completes the pair on the input side.Changes
src/utils/duration.rs:parse_input_to_minutes(single source of truth:H:MMwith minutes 0-59, or decimal hours, returns whole minutes, rejects empty/negative/malformed) andfmt_input(parseable, preference-aware pre-fill:H:MMwhen the duration-format pref ishm, else a trimmed decimal). Unit tests added for both.src/pages/time.rs: both Hours inputs switch fromtype="number"to free-text (droppingstep/min/max) with a placeholder and help text. Both submit handlers parse viaparse_input_to_minutesand enforce0 < minutes <= 1440(24h). The edit form pre-fills withfmt_input, so a 10-minute entry shows0:10/0.17instead of0.16666666666666666. No change to the sharedInputcomponent.Verification
just pre-commit(pinned rust 1.94 image) passes: fmt, clippy-D warnings,cargo check --target wasm32-unknown-unknown, and all 90 lib tests (including 4 new duration tests).Acceptance criteria
0:30-> 30 min,1:30-> 90 min,2:05-> 125 min.2.5-> 150,0.25-> 15,8-> 480.1:60,1:,abc, empty,0, negative, > 24h) rejected with a message naming both formats; nothing saved.duration_minutes.parse_input_to_minutesunit-tested.🤖 Generated with Claude Code
The "Hours" field on both the Log Time (create) and Edit Time Entry forms now accepts clock-style H:MM input (e.g. "0:30" = 30 min, "1:30" = 90 min) in addition to decimal hours ("2.5"). Previously the field was an <input type="number"> (PMS-233 added decimal support), which blocks the colon outright, so H:MM could never be typed. PMS-265 already added H:MM as a display option; this completes the pair by accepting it as input. src/utils/duration.rs: add parse_input_to_minutes (the single source of truth for parsing the field: H:MM with minutes 0-59, or decimal hours, returning whole minutes and rejecting empty/negative/malformed input) and fmt_input (a parseable, preference-aware pre-fill that emits H:MM when the duration-format pref is hm, else a trimmed decimal). Unit tests cover H:MM, decimal, boundaries, and reject cases plus the decimal round-trip. src/pages/time.rs: both Hours inputs switch from type="number" to free-text (dropping the now-meaningless step/min/max) with a placeholder and help text showing both formats. Both submit handlers parse via parse_input_to_minutes and enforce 0 < minutes <= 1440 (24h), replacing the f64 parse and the * 60 conversion. The edit form pre-fills with fmt_input, so a 10-minute entry shows "0:10" / "0.17" instead of "0.16666666666666666". No change to the shared Input component was needed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>