Skip to main content

Module format

Module format 

Source
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 SystemTime as an absolute YYYY-MM-DD date in the system local zone.
human_int
Format an integer count with . thousands separators (European style).
human_size
human_size_parts
Format bytes as (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 singular when n == 1, plural otherwise. Trivial helper, but having one place beats if n == 1 { "x" } else { "xs" } sprinkled across six call sites — and grep-ing for pluralize is easier than chasing inline ternaries.
tildify
Render path with the user’s home directory collapsed to ~/. Falls back to the full display() form when the path isn’t under home or when home is None.
truncate_with_ellipsis
Truncate s to at most width display columns, replacing the tail with when it would otherwise overflow. Width is measured by chars().count() — fine for the cache-folder names we render, which are ASCII-ish in practice and don’t carry wide CJK or grapheme clusters.