Skip to content

wip: round displayed durations to nearest 15 minutes#16

Open
Flyrell wants to merge 1 commit into
mainfrom
feat/duration-rounding
Open

wip: round displayed durations to nearest 15 minutes#16
Flyrell wants to merge 1 commit into
mainfrom
feat/duration-rounding

Conversation

@Flyrell
Copy link
Copy Markdown
Owner

@Flyrell Flyrell commented Jun 1, 2026

Summary

Displayed durations are now rounded to the nearest 15-minute interval. The rounding is display-only — stored time stays precise and logged data is never mutated.

  • Added RoundMinutes(m, interval int) and FormatMinutesRounded(m int) in internal/entry/duration.go, with table-driven tests (duration_test.go).
  • Swapped FormatMinutesFormatMinutesRounded at all display-only call sites:
    • status, history
    • log add / log remove / log edit display lines
    • report table view and PDF export
    • report overlay labels (entry selector, remove confirmation)
    • find.go, placement.go error message
  • Deliberately kept the unrounded FormatMinutes at the three interactive input-default sites that round-trip through ParseDuration (log_edit.go:368, report_overlay.go:94, report_overlay.go:244), so editing an entry never silently mutates its stored duration.
  • Added CHANGELOG.md with an [Unreleased] > Changed entry.

RoundMinutes rounds midpoints up (e.g. with interval 15: 7→0, 8→15) and returns the value unchanged for non-positive minutes or interval <= 1.

How to test

  • task test — covers the new table-driven tests for RoundMinutes / FormatMinutesRounded.
  • Manual: run hourgit status, hourgit history, and hourgit report on data with non-15-aligned durations and confirm displayed times snap to the nearest 15 minutes while the stored entries remain unchanged.
  • Edit an entry (hourgit log edit <hash>) and confirm the duration prompt is pre-filled with the precise (unrounded) value, so saving without changes does not alter stored time.

Notes for reviewer

  • Scope is intentionally narrow: only display call sites changed. The input-default sites were left unrounded on purpose to avoid data drift through the edit round-trip.
  • No storage format or data-model changes.

🤖 Generated with Claude Code

Displayed durations are now rounded to the nearest 15-minute interval
across status, history, report (table and PDF export), and log output.
This keeps timesheets readable without altering the underlying data:
stored time remains precise and only the presentation is rounded.

Adds RoundMinutes(m, interval) and FormatMinutesRounded(m) in
internal/entry/duration.go, with table-driven tests. Display-only call
sites swap FormatMinutes for FormatMinutesRounded.

Interactive input defaults that round-trip through ParseDuration
(log_edit.go duration prompt, report_overlay.go form fields) deliberately
keep the unrounded FormatMinutes, so editing an entry never silently
mutates its stored duration.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Flyrell Flyrell force-pushed the feat/duration-rounding branch from 5702f9e to 46628e9 Compare June 1, 2026 16:47
@Flyrell Flyrell changed the title feat: round displayed durations to nearest 15 minutes wip: round displayed durations to nearest 15 minutes Jun 1, 2026
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.

1 participant