Skip to main content

parse_duration

Function parse_duration 

Source
pub fn parse_duration(s: &str) -> u64
Expand description

Parse a human-readable duration string (e.g., “30d”, “2w”, “6M”) into seconds.

Supported suffixes:

  • h — hours
  • d — days
  • w — weeks
  • M — months (30 days)
  • y — years (365 days)

If no suffix is provided, the value is treated as raw seconds. If parsing fails, returns 0.