19 May 2021 15:40:16 UTC
- Distribution: Time-Duration-Parse
- Module version: 0.16
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (0)
- Testers (2900 / 0 / 0)
- KwaliteeBus factor: 2
- 100.00% Coverage
- License: perl_5
- Perl: v5.6.0
- Activity24 month
- Download (11.53KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version
Time::Duration::Parse - Parse string that represents time duration
use Time::Duration::Parse; my $seconds = parse_duration("2 minutes and 3 seconds"); # 123
Time::Duration::Parse is a module to parse human readable duration strings like 2 minutes and 3 seconds to seconds.
use Time::Duration::Parse; use Time::Duration; my $seconds = int rand 100000; is( parse_duration(duration_exact($seconds)), $seconds );
$seconds = parse_duration($string);
Parses duration string and returns seconds. When it encounters an error in a given string, it dies with an exception saying "Unknown timespec: blah blah blah". This function is exported by default.
Time::Duration::Parse::More has the same interface as this module, but supports more expressions and memoization.
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.
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
Tatsuhiko Miyagawa <firstname.lastname@example.org>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Some internal code is taken from Cache and Cache::Cache modules on CPAN.
Module Install Instructions
To install Time::Duration::Parse, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install Time::Duration::Parse
For more information on module installation, please visit the detailed CPAN module installation guide.