Skip to main content

Module human

Module human 

Source
Expand description

Human-readable numbers for messages: durations, sizes and counts, shared by the command line and the desktop app so both say the same thing (D104).

Numbers are plain digits with . as the decimal mark and no thousands separators, as the JSON outputs write them: the SI allows the comma as a decimal marker and never inserts commas or dots between digit groups (“Neither dots nor commas are ever inserted in the spaces between groups”), grouping being “a matter of choice” not always followed in “scripts to be read by a computer” (BIPM SI Brochure, 9th ed., §5.4.4), and speech synthesisers read “2,637” as a decimal in most languages. Unit symbols follow the number after a space (§5.4.3): s; min and h, accepted for use with the SI (Table 8); and bytes, B, with the SI’s decimal prefixes kB, MB, GB. Every value is rounded before its unit is chosen, so the boundaries read naturally (59.96 s is 1 min 00 s, not 60.0 s; 999 999 bytes is 1.0 MB, not 1000 kB).

Modules§

separators
Separators of human-readable messages, in one place.

Functions§

bytes
17 B, 512 kB, 42.0 MB, 1.2 GB: decimal multiples with SI prefix symbols (lower-case k for kilo; BIPM SI Brochure, 9th ed., Table 7), one decimal below 100.
duration
0.21 s, 12.3 s, 4 min 05 s, 1 h 02 min (hours keep counting past a day).
plural
"1 sequence" / "3 sequences".