Expand description
Pure formatters: human-readable bytes, durations, and display labels.
Functions§
- human_
age - human_
count - Format a positive floating-point count with k / M / G / T suffixes. Sub-1000 values render as integers. Used for “impact points” (size × age).
- human_
date - Format a
SystemTimeas an absoluteYYYY-MM-DDdate in the system local zone. - human_
int - Format an integer count with
.thousands separators (European style). - human_
size - human_
size_ parts - Format
bytesas(number, unit)so callers that stack values can right-align number and unit in separate sub-columns. Number is up to 4 chars ("1023","9.9","999"); unit is 1 ("B") or 3 ("KiB"…"TiB"). - pluralize
- Pick
singularwhenn == 1,pluralotherwise. Trivial helper, but having one place beatsif n == 1 { "x" } else { "xs" }sprinkled across six call sites — and grep-ing forpluralizeis easier than chasing inline ternaries. - tildify
- Render
pathwith the user’s home directory collapsed to~/. Falls back to the fulldisplay()form when the path isn’t underhomeor whenhomeisNone. - truncate_
with_ ellipsis - Truncate
sto at mostwidthdisplay columns, replacing the tail with…when it would otherwise overflow. Width is measured bychars().count()— fine for the cache-folder names we render, which are ASCII-ish in practice and don’t carry wide CJK or grapheme clusters.