Time::Duration::Parse(3pm)

Time::Duration::Parse3pm

Parse string that represents time duration

Usage

  use Time::Duration::Parse;
  my $seconds = parse_duration("2 minutes and 3 seconds"); # 123

Overview

Time::Duration::Parse is a module to parse human readable duration strings like 2 minutes and 3 seconds to seconds.

It does the opposite of "duration_exact" in Time::Duration function in Time::Duration and is roundtrip safe. So, the following is always true.

  use Time::Duration::Parse;
  use Time::Duration;
  my $seconds = int rand 100000;
  is( parse_duration(duration_exact($seconds)), $seconds );

Functions

parse_duration
  $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.

Repository

<https://github.com/neilb/Time-Duration-Parse>

Releases

9 releases since Debian 5.0 (Lenny); the text changed 5 times.

  1. 5.0–7
  2. 8
  3. 9
  4. 10
  5. 11
  6. 12–13

Author

Tatsuhiko Miyagawa <[email protected]>

From libtime-duration-parse-perl 0.16-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.