[][src]Function humantime::format_duration

pub fn format_duration(val: Duration) -> FormattedDuration

Formats duration into a human-readable string

Note: this format is guaranteed to have same value when using parse_duration, but we can change some details of the exact composition of the value.


use std::time::Duration;
use humantime::format_duration;

let val1 = Duration::new(9420, 0);
assert_eq!(format_duration(val1).to_string(), "2h 37m");
let val2 = Duration::new(0, 32_000_000);
assert_eq!(format_duration(val2).to_string(), "32ms");