feat(time): accept H:MM input in the Log Time hours field (PMS-314) #164

Merged
longjacksonle merged 1 commit from feat/PMS-314-time-hhmm-input into main 2026-06-15 22:07:48 +02:00

Implements PMS-314.

What

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) alongside decimal hours (2.5). The field was an <input type="number"> (PMS-233 added decimals), which blocks the colon, so H:MM could never be typed. PMS-265 already added H:MM as 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:MM with minutes 0-59, or decimal hours, returns whole minutes, rejects empty/negative/malformed) and fmt_input (parseable, preference-aware pre-fill: H:MM when the duration-format pref is hm, else a trimmed decimal). Unit tests added for both.
  • src/pages/time.rs: both Hours inputs switch from type="number" to free-text (dropping step/min/max) with a placeholder and help text. Both submit handlers parse via parse_input_to_minutes and enforce 0 < minutes <= 1440 (24h). 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.

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.
  • Decimal still works: 2.5 -> 150, 0.25 -> 15, 8 -> 480.
  • Malformed input (1:60, 1:, abc, empty, 0, negative, > 24h) rejected with a message naming both formats; nothing saved.
  • Edit form pre-fills a clean, parseable value that round-trips to the same duration_minutes.
  • Create and edit forms behave identically.
  • parse_input_to_minutes unit-tested.

🤖 Generated with Claude Code

Implements PMS-314. ## What 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) alongside decimal hours (`2.5`). The field was an `<input type="number">` (PMS-233 added decimals), which blocks the colon, so `H:MM` could never be typed. PMS-265 already added `H:MM` as 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:MM` with minutes 0-59, or decimal hours, returns whole minutes, rejects empty/negative/malformed) and `fmt_input` (parseable, preference-aware pre-fill: `H:MM` when the duration-format pref is `hm`, else a trimmed decimal). Unit tests added for both. - `src/pages/time.rs`: both Hours inputs switch from `type="number"` to free-text (dropping `step`/`min`/`max`) with a placeholder and help text. Both submit handlers parse via `parse_input_to_minutes` and enforce `0 < minutes <= 1440` (24h). 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. ## 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 - [x] `0:30` -> 30 min, `1:30` -> 90 min, `2:05` -> 125 min. - [x] Decimal still works: `2.5` -> 150, `0.25` -> 15, `8` -> 480. - [x] Malformed input (`1:60`, `1:`, `abc`, empty, `0`, negative, > 24h) rejected with a message naming both formats; nothing saved. - [x] Edit form pre-fills a clean, parseable value that round-trips to the same `duration_minutes`. - [x] Create and edit forms behave identically. - [x] `parse_input_to_minutes` unit-tested. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
feat(time): accept H:MM input in the Log Time hours field (PMS-314)
All checks were successful
Check / clippy + fmt + tests (pull_request) Successful in 1m25s
Create release / Create release from merged PR (pull_request) Has been skipped
99860177eb
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>
longjacksonle deleted branch feat/PMS-314-time-hhmm-input 2026-06-15 22:07:49 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/mokosh-apps!164
No description provided.