1Time::Duration::Parse(3U)ser Contributed Perl DocumentatiToinme::Duration::Parse(3)
2
3
4
6 Time::Duration::Parse - Parse string that represents time duration
7
9 use Time::Duration::Parse;
10
11 my $seconds = parse_duration("2 minutes and 3 seconds"); # 123
12
14 Time::Duration::Parse is a module to parse human readable duration
15 strings like 2 minutes and 3 seconds to seconds.
16
17 It does the opposite of duration_exact function in Time::Duration and
18 is roundtrip safe. So, the following is always true.
19
20 use Time::Duration::Parse;
21 use Time::Duration;
22
23 my $seconds = int rand 100000;
24 is( parse_duration(duration_exact($seconds)), $seconds );
25
27 parse_duration
28 $seconds = parse_duration($string);
29
30 Parses duration string and returns seconds. When it encounters an
31 error in a given string, it dies an exception saying "Unknown
32 timespec: blah blah blah". This function is exported by default.
33
35 Tatsuhiko Miyagawa <miyagawa@bulknews.net>
36
38 This library is free software; you can redistribute it and/or modify it
39 under the same terms as Perl itself.
40
41 Some internal code is taken from Cache and Cache::Cache modules on
42 CPAN.
43
45 Date::Manip, DateTime::Format::Duration,
46 <http://use.perl.org/~miyagawa/journal/30310>
47
49 Hey! The above document had some coding errors, which are explained
50 below:
51
52 Around line 91:
53 You forgot a '=back' before '=head1'
54
55
56
57perl v5.12.0 2008-05-30 Time::Duration::Parse(3)