Function humantime::parse_duration
[−]
[src]
pub fn parse_duration(s: &str) -> Result<Duration, Error>
Parse duration object
The duration object is a concatenation of time spans. Where each time
span is an integer number and a suffix. Supported suffixes:
* nsec
, ns
-- microseconds
* usec
, us
-- microseconds
* msec
, ms
-- milliseconds
* seconds
, second
, sec
, s
* minutes
, minute
, min
, m
* hours
, hour
, hr
, h
* days
, day
, d
* weeks
, week
, w
* months
, month
, M
-- defined as 30.44 days
* years
, year
, y
-- defined as 365.25 days
Examples:
use std::time::Duration; use humantime::parse_duration; assert_eq!(parse_duration("2h 37min"), Ok(Duration::new(9420, 0)));