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

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.

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

Comment on RFC: DateTime::TimeAgo
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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://876827]
Approved by moritz
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2014-09-22 04:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (178 votes), past polls