Skip to main content

Module units

Module units 

Source
Expand description

Human-readable sizes and ages, and parsers for their command-line forms.

Enums§

Units
How sizes are displayed.

Functions§

format_age
Format an age in its largest whole unit, 45 minutes, 3 days, 11 months, or in years to one decimal, 1 year, 2.5 years. Months and years have the lengths parse_age gives them, so a parsed 1y formats as 1 year.
format_count
Format a count with thousands separators: 300,020.
format_size
Format a byte count with three significant digits: 999 B, 1.50 kB, 52.3 GB, 140 GB.
parse_age
Parse 90min, 12h, 30d, 2w, 6mo, 1y. A bare m is rejected as ambiguous between minutes and months.
parse_size
Parse 500, 100MB, 1.5 GiB, 2g. Decimal units are powers of 1000, *iB units powers of 1024. Integer amounts are exact.