Function parse

Source
pub fn parse(input: &str) -> Result<Duration, Error>
Expand description

Parses a string into a Duration, ignoring whitespaces and commas.

§Supported Units

  • ms, msec/msecs, milliseconds
  • s, sec/secs, seconds
  • m, min/mins, minutes
  • h, hr/hrs, hours

§Examples

use durstr::parse;
use std::time::Duration;

let d = parse("2 minutes, 12 seconds").unwrap();
assert_eq!(d, Duration::from_secs(132));