Skip to main content

parse_duration

Function parse_duration 

Source
pub fn parse_duration(s: &str) -> Result<Duration, String>
Expand description

Parse a duration suffix-string. Accepts:

  • <n>s — seconds
  • <n>m — minutes
  • <n>h — hours
  • <n>d — days
  • <n>w — weeks
  • bare integer — seconds (back-compat with raw numeric input)

Whitespace is trimmed. 0 (any unit) disables the cap.