Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

RFC: DateTime::TimeAgo

by Sixtease (Friar)
on Dec 13, 2010 at 09:14 UTC ( #876827=perlmeditation: print w/replies, xml ) Need Help??

A new module for formatting intervals in the manner of "XXX ago" just arose. Your insights are welcome.

use strict; use warnings; print "Just Another Perl Hacker\n";

Replies are listed 'Best First'.
Re: RFC: DateTime::TimeAgo
by moritz (Cardinal) on Dec 13, 2010 at 09:40 UTC

    Thank you for sharing your code on the CPAN.

    I like your module, but not the naming.

    For somebody who doesn't know the js library it was inpired from, the name is mostly meaningless, and not something one would search for.

    Since DateTime::Format::Human::Duration exists, maybe use DateTime::Format::Fuzzy::Duration instead? Or if you don't want to rewrite it as a ::Format module, use DateTime::Duration::Fuzzy

    Regarding the API, I think it would make sense to all the user to pass in DateTime::Duration objects, not only DateTime objects.

    Finally you can replace the get_datetime_from_timestamp function with DateTime->from_epoch( epoch => $your_time_stamp).

      I agree 100%
Re: RFC: DateTime::TimeAgo
by Sixtease (Friar) on Dec 15, 2010 at 12:56 UTC

    Thank you for the suggestions.

    The output depends not only on the durations itself but also on the $now time -- 4 days ago can be output as 'this week' or 'last week' depending on the current DOW. That's why I'll keep the current interface of two DT objects until a better option is found. The same thing speaks also against making it a duration format.

    use strict; use warnings; print "Just Another Perl Hacker\n";
Re: RFC: DateTime::TimeAgo
by apl (Monsignor) on Dec 26, 2010 at 18:22 UTC
    Clicking on the link results in CPAN "Not Found" error.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://876827]
Approved by moritz
and the radiator hisses contentedly...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (3)
As of 2018-07-19 21:35 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (420 votes). Check out past polls.