Humanly
A pure Rust crate to convert numbers, sizes, durations, times, and percentages into human-readable formats.
Crate Modules
HumanNumber— Convert numbers to K/M/B/T notation (concise) or word format (full).HumanSize— Convert bytes to human-readable units (KiB, MiB…).HumanDuration— Show how long ago a timestamp occurred in short or long format.HumanTime— ConvertDurationinto H:M:S strings.HumanPercent— Round floats and display as percentage string.
Output Formats
Each type provides .concise() and .full() methods for different output styles:
use HumanNumber;
// Concise: "1.8k"
println!;
// Full: "1.8 thousand"
println!;
Examples
use ;
use ;
// HumanNumber
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
// HumanSize
// Binary (default, 1024-based)
assert_eq!;
assert_eq!;
// Decimal (SI, 1000-based)
let human_size = from;
assert_eq!;
assert_eq!;
// HumanDuration
let now = now;
let result = from.concise;
assert!;
// HumanTime
assert_eq!;
assert_eq!;
// HumanPercent
assert_eq!;
assert_eq!;