Skip to content

duration

Parsing and formatting of durations as short human-readable strings (1h30m).

The strings use the units ms, s, m, h, d and w. Values are std::time::Duration.

Cargo feature duration (enabled by default). To compile only this module:

cargo add helpers4 --no-default-features --features duration

or in Cargo.toml:

[dependencies]
helpers4 = { version = "0.0.5", default-features = false, features = ["duration"] }

Import path: helpers4::duration.

ItemWhat it does
formatFormats duration as a short human-readable string such as "1h 30m 5s".
parseParses a human-written duration such as "1h30m", "2d" or "500ms".

Documented on the page of the helper that returns them.

TypeReturned by
ParseDurationErrorparse