Skip to content

fix(timer): show days in formatUsageDuration for durations >= 24h#228

Merged
sirmalloc merged 4 commits intosirmalloc:mainfrom
Jaahuo:fix/210-format-days
Mar 15, 2026
Merged

fix(timer): show days in formatUsageDuration for durations >= 24h#228
sirmalloc merged 4 commits intosirmalloc:mainfrom
Jaahuo:fix/210-format-days

Conversation

@Jaahuo
Copy link
Contributor

@Jaahuo Jaahuo commented Mar 13, 2026

Summary

  • formatUsageDuration() now displays a days component for durations >= 24 hours (e.g. 1d 12hr 30m instead of 36hr 30m)
  • Applies to both normal and compact formats (1d12h30m in compact mode)
  • Zero duration now shows 0m instead of 0hr/0h
  • Simplified implementation: unified compact/normal into a single code path

Fixes #210

Test plan

  • New test cases for normal format with days (1d 1hr, 1d 12hr 30m, 7d)
  • New test cases for compact format with days (1d1h, 1d12h30m, 7d)
  • Zero duration returns 0m in both modes
  • Existing sub-24h tests still pass
  • bun run lint passes

Jaahuo added 2 commits March 13, 2026 13:46
Durations of 24+ hours now display a days component instead of
raw hours (e.g. "1d 12hr 30m" instead of "36hr 30m"). Applies to
both normal and compact formats. Fixes sirmalloc#210.
…ration

Unify compact/normal branches into a single code path differing only
in hour label and separator. Zero duration now displays "0m" instead
of "0hr"/"0h".
@jubishop
Copy link

I created something similar but a bit different here #235. mine doesnt automatically show days: it adds another key bind: "y", (out of "day" but d and a are taken) that sets a format option to times to show days and hours instead of hours and minutes.

Default weekly reset timers to day-based formatting while adding an hours-only toggle and keeping preview text aligned with live rendering.

Also move custom keybind visibility back into widgets and clear disabled toggle metadata when those options become unavailable in the editor.
# Conflicts:
#	src/utils/renderer.ts
@sirmalloc sirmalloc merged commit d1e35aa into sirmalloc:main Mar 15, 2026
3 checks passed
@sirmalloc
Copy link
Owner

I'll publish this whenever the next release goes out, I'm trying to get a few more PRs merged in before then.

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.

formatUsageDuration should show days for durations >= 24h

3 participants