.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Time::Duration::Parse 3pm" .TH Time::Duration::Parse 3pm "2021-09-03" "perl v5.32.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Time::Duration::Parse \- Parse string that represents time duration .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Time::Duration::Parse; \& \& my $seconds = parse_duration("2 minutes and 3 seconds"); # 123 .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Time::Duration::Parse is a module to parse human readable duration strings like \fI2 minutes and 3 seconds\fR to seconds. .PP It does the opposite of \*(L"duration_exact\*(R" in Time::Duration function in Time::Duration and is roundtrip safe. So, the following is always true. .PP .Vb 2 \& use Time::Duration::Parse; \& use Time::Duration; \& \& my $seconds = int rand 100000; \& is( parse_duration(duration_exact($seconds)), $seconds ); .Ve .SH "FUNCTIONS" .IX Header "FUNCTIONS" .IP "parse_duration" 4 .IX Item "parse_duration" .Vb 1 \& $seconds = parse_duration($string); .Ve .Sp Parses duration string and returns seconds. When it encounters an error in a given string, it dies with an exception saying \*(L"Unknown timespec: blah blah blah\*(R". This function is exported by default. .SH "SEE ALSO" .IX Header "SEE ALSO" Time::Duration::Parse::More has the same interface as this module, but supports more expressions and memoization. .PP Time::Duration can be used for the reverse of this module: given a number of seconds it will provide an English description of the duration. .PP Time::Duration::Object provides an \s-1OO\s0 interface to Time::Duration. .PP Time::Duration::LocaleObject provides an \s-1OO\s0 interface to the \&\f(CW\*(C`Time::Duration::??\*(C'\fR modules, which provide language-specific versions of Time::Duration. .PP DateTime::Format::Duration can be used to parse natural language descriptions of durations, returning an instance of DateTime::Duration, which can then be converted to seconds using the \f(CW\*(C`in_units()\*(C'\fR method. .SH "REPOSITORY" .IX Header "REPOSITORY" .SH "AUTHOR" .IX Header "AUTHOR" Tatsuhiko Miyagawa .SH "COPYRIGHT" .IX Header "COPYRIGHT" This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .PP Some internal code is taken from Cache and Cache::Cache modules on \&\s-1CPAN.\s0