Function jackdauer::hours[][src]

pub fn hours(input: &str) -> Result<u64, Error>
Expand description

Returns the total number of hours contained in the parsed human readable duration.

Examples

use jackdauer::hours;

assert_eq!(hours("60 minutes"), Ok(1));
assert_eq!(hours("1 hour"), Ok(1));
assert_eq!(hours("2 hours"), Ok(2));
assert_eq!(hours("3 days"), Ok(72));
assert_eq!(hours("4 weeks"), Ok(672));
assert_eq!(hours("5 months"), Ok(3_600));
assert_eq!(hours("6 years"), Ok(52_560));
assert_eq!(hours("1 minute"), Ok(0));