Skip to content

formatUsageDuration should show days for durations >= 24h #210

@jetm

Description

@jetm

Problem

The weekly-reset-timer and other usage duration widgets display total hours and minutes (e.g., 36hr 30m), even when the duration exceeds 24 hours. For weekly reset timers that can show up to ~168 hours, this is hard to parse at a glance.

Expected behavior

Durations >= 24h should include days, e.g.:

  • 36hr 30m -> 1d 12hr 30m
  • 168hr -> 7d
  • 5hr 20m -> unchanged (below 24h)

Compact mode similarly: 36h30m -> 1d12h30m

Location

src/utils/usage-windows.ts, formatUsageDuration() (line 92-106)

Suggested fix

Add a days calculation before the hours/minutes logic:

const days = Math.floor(clampedMs / (1000 * 60 * 60 * 24));
const elapsedHours = Math.floor((clampedMs % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));

Then prepend ${days}d when days > 0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions