Function duration_str::parse_std[][src]

pub fn parse_std<S: Into<String>>(input: S) -> Result<Duration>
Expand description

convert Into to std::time::Duration

Example


use duration_str::parse;
use std::time::Duration;

let duration = parse("1d").unwrap();
assert_eq!(duration,Duration::new(24*60*60,0));

let duration = parse("3m+31").unwrap();
assert_eq!(duration,Duration::new(211,0));

let duration = parse("3m + 31").unwrap();
assert_eq!(duration,Duration::new(211,0));

let duration = parse("1m*10").unwrap();
assert_eq!(duration,Duration::new(600,0));

let duration = parse("1m * 10").unwrap();
assert_eq!(duration,Duration::new(600,0));