Skip to content

feat: hm-common crate + compact duration formatting#169

Merged
markovejnovic merged 1 commit into
mainfrom
feat/v1
Jul 23, 2026
Merged

feat: hm-common crate + compact duration formatting#169
markovejnovic merged 1 commit into
mainfrom
feat/v1

Conversation

@markovejnovic

@markovejnovic markovejnovic commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

cleaner formatting

Introduce the hm-common crate, seeded with a formatting module: a
sealed CompactDuration extension trait on std::time::Duration returning
a StopwatchDurationDisplay (allocation-free Display wrapper). Rendering
follows humantime semantics — lossless, most-significant unit first,
zero units omitted — in compact notation (1s500ms, 1h1m1s, 2h, 1d2h).
Covered by rstest cases plus proptest round-trip/well-formedness.

Wire it into hm-render's progress output, replacing the hand-rolled
format_duration (which capped at minutes, so >=1h rendered as e.g.
"61m1s"). Machine-facing "duration={ms}ms" log lines stay integer ms.

Also adopt the human_units crate for byte-size rendering, collapsing
four hand-rolled formatters (human_mb, human_bytes, and an inline mb
closure) into `.format_size()`. Output shifts to correct IEC labels
(e.g. "6 MiB" instead of the mislabeled 1024-base "6.0 MB").
@markovejnovic
markovejnovic marked this pull request as ready for review July 23, 2026 07:42
@markovejnovic
markovejnovic merged commit 944364d into main Jul 23, 2026
15 of 17 checks passed
@markovejnovic
markovejnovic deleted the feat/v1 branch July 23, 2026 07:42
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