Skip to main content

parse_duration

Function parse_duration 

Source
pub fn parse_duration(s: &str) -> Result<Duration, String>
Available on crate feature time only.
Expand description

Parse a duration from a human-readable string.

Supports single units ("100ms", "5s", "2m", "1h", "1d") as well as compound expressions separated by whitespace ("1h 30m", "2d 6h 30m 500ms"). A bare number without a suffix is treated as fractional seconds.

ยงErrors

Returns an error if any chunk cannot be parsed.