streamd timesheet report --use-minutes #79
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
If the --minutes-flag is set, the time is displayed with minuts (8:30) instead of hours with fractions (8.5) everywhere.
Implementation Plan
Overview
Add a
--minutes/-mflag to thestreamd timesheetcommand that displays time asHH:MM(e.g.,8:30) instead of decimal hours (e.g.,8.5h).Files to Modify
src/cli/args.rs--minutes/-mflag to Timesheet commandsrc/main.rssrc/cli/commands/timesheet.rsImplementation Steps
Step 1: Add CLI flag in
src/cli/args.rsConvert
Timesheetfrom a unit variant to a struct variant with the flag:Step 2: Update
src/main.rsto pass the flagModify the match arm for
Commands::Timesheetto extract and pass theminutesflag to therun()function.Step 3: Update formatting functions in
src/cli/commands/timesheet.rs3a. Update function signature:
3b. Modify
format_hours()to support minutes format:3c. Modify
format_diff()to support minutes format:3d. Update all call sites (approximately 10 locations):
Step 4: Update tests
Add unit tests for the new formatting behavior:
format_hours()withuse_minutes=truefor various valuesformat_diff()withuse_minutes=truefor positive and negative valuesExample Output
Current (decimal hours):
With
--minutesflag:Testing
Notes
-1:30(minus sign before time)Implementation Summary
PR: #82
Time taken: ~10 minutes
Tokens used: ~15k
What was done
Implemented the
-m/--minutesflag exactly as planned. The changes were straightforward:TimesheetCLI variant from a unit to a struct variant with aminutes: boolflaguse_minutes: boolparameter toformat_hours()andformat_diff(), then propagated it throughprint_month(),print_cumulative_balance(),print_warnings(), andrun()Findings
OutsidePeriodwarning used an inline{:.1}hformat literal rather than callingformat_hours()— updated it to useformat_hours()for consistency