SYNOPSIS use Time::Duration::Parse::AsHash; my $res = parse_duration("2 minutes and 3 seconds"); # => {minutes=>2, seconds=>3} $res = parse_duration("2 minutes and 3 seconds", 1); # => 123 DESCRIPTION Time::Duration::Parse::AsHash is like Time::Duration::Parse except: * By default it returns a hashref of parsed duration elements instead of number of seconds There are some circumstances when you want this, e.g. when feeding into DateTime::Duration and you want to count for leap seconds. To return number of seconds like Time::Duration::Parse, pass a true value as the second argument. * Seconds are not rounded by default For example: "0.1s" or 100ms will return result { seconds => 0.1 }. Also, in addition to 01:02:03 being recognized as 1h2min3s, 01:02:03.4567 will also be recognized as 1h2min3.4567s. * Extra elements recognized milliseconds (or ms). This will be returned in seconds key. microseconds. This will also be returned in seconds key. nanoseconds (or ns). This will also be returned in seconds key. decades. This will be returned in years key. * It has a lower startup overhead By avoiding modules like Carp and Exporter::Lite, even strict and warnings. FUNCTIONS parse_duration($str [, $as_secs ]) => hash Parses duration string and returns hash (unless when the second argument is true, in which case will return the number of seconds). Dies on parse failure. This function is exported by default. Note that number of seconds is an approximation: leap seconds are not regarded (so a minute is always 60 seconds), a month is 30 days, a year is 365 days. SEE ALSO Time::Duration::Parse