Function humantime::parse_duration
source · Expand description
Parse duration object 1hour 12min 5s
The duration object is a concatenation of time spans. Where each time span is an integer number and a suffix. Supported suffixes:
nsec
,ns
– nanosecondsusec
,us
– microsecondsmsec
,ms
– millisecondsseconds
,second
,sec
,s
minutes
,minute
,min
,m
hours
,hour
,hr
,h
days
,day
,d
weeks
,week
,w
months
,month
,M
– defined as 30.44 daysyears
,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)));
assert_eq!(parse_duration("32ms"), Ok(Duration::new(0, 32_000_000)));