in reply to Perl Time Ago in Words

Working from bottom to top, some suggestions for making this post more useful:

IOW, I think you can sum up these observations as a call to "write a better tease" ...
        and, that said, yes, I, for one, find this so interesting1 as to be persuaded to upvote a post whose content seems (to me) in serious need of improvement.

Update:   1 Where the value of "interesting" is "how does the code handle the many edge cases?"

Replies are listed 'Best First'.
Re^2: Perl Time Ago in Words
by mla12 (Acolyte) on Jul 05, 2015 at 19:29 UTC

    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.

      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!

      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 :-)