in reply to Re: Perl Time Ago in Words
in thread Perl Time Ago in Words

Sorry my message was lacking.

The module is currently available here: https://github.com/mla/time-ago

Namespace suggestions welcome. I also put it on PrePan http://prepan.org/module/nY5Y569jtrb

Some examples of what approximate means:

#!/usr/bin/env perl use strict; use warnings; use Time::Ago; my $hour = 60 * 60; my $day = 86400; foreach (0, 65, $hour * 3.5, $day * 376, $day * 365 * 14.7) { printf "%10s secs: %s\n", $_, Time::Ago->in_words($_); }

Output:

0 secs: less than 1 minute 65 secs: 1 minute 12600 secs: about 4 hours 32486400 secs: about 1 year 463579200 secs: over 14 years

The precise rules are detailed on the github page.

Replies are listed 'Best First'.
Re^3: Perl Time Ago in Words
by 1nickt (Canon) on Jul 05, 2015 at 21:47 UTC

    You should offer to merge your code with Time::Duration. Maybe as a sub-module -- Time::Duration::Ago (sweet!)

    Remember: Ne dederis in spiritu molere illegitimi!
Re^3: Perl Time Ago in Words
by soonix (Chancellor) on Jul 09, 2015 at 08:09 UTC

    Suggestion: although it deviates from the original (rail) version:

    Change the singulars from "1 unit" to "a unit", at least for the minutes
    (or change the 65 seconds to "about 1 minute").

    This would be more consistent. And "1 minute" sounds more exact than it is :-)