Function duration_str::parse_chrono [−][src]
pub fn parse_chrono<S: Into<String>>(input: S) -> Result<Duration>
Expand description
convert Intochrono::Duration
Example
use duration_str::parse_chrono;
use chrono::Duration;
let duration = parse_chrono("1d").unwrap();
assert_eq!(duration,Duration::seconds(24*60*60));
let duration = parse_chrono("3m+31").unwrap();
assert_eq!(duration,Duration::seconds(211));
let duration = parse_chrono("3m + 31").unwrap();
assert_eq!(duration,Duration::seconds(211));
let duration = parse_chrono("1m*10").unwrap();
assert_eq!(duration,Duration::seconds(600));
let duration = parse_chrono("1m * 10").unwrap();
assert_eq!(duration,Duration::seconds(600));