[Omaha.pm] DateTime::Duration ->days()

Sterling Hanenkamp sterling at hanenkamp.com
Sat Jan 15 22:24:25 PST 2011


In DateTime, you want delta_days... twice.

my $start = DateTime->new(year => 2007, month => 5, day => 15);
my $end = DateTime->new(year => 2011, month => 1, day => 14);
say sprintf('$%0.2f', 1025 / $end->delta_days($start)->delta_days);

DateTime is popular because it is accurate, common, standard, extensible,
and popular (since popularity is a property that feeds itself), not because
it is fast or easy to use by itself (it is neither in my experience).

On Fri, Jan 14, 2011 at 9:17 PM, Jay Hannah <jhannah at mutationgrid.com>wrote:

> On Jan 14, 2011, at 9:03 PM, Jay Hannah wrote:
> > What the heck? Why is DateTime so popular? Date::Calc and Class::Date
> make this trivial.
>
> See? Easy...
>
>
> $ cat j2.pl
> use 5.12.0;
> use Date::Calc qw(Delta_Days);
>
> say sprintf('$%0.2f', 1025 / Delta_Days(2007, 5, 15, 2011, 1, 14));
>
> $ perl j2.pl
> $0.76
>
>
> My laptop died today. And that's how much money it cost me per day I owned
> it. Used it daily. Not bad.  :)
>
>   http://www.facebook.com/photo.php?pid=1500762&l=fe015d08cb&id=1032415362
>
> Thanks,
>
> Jay Hannah
> Software Architect
> jhannah at mutationgrid.com | http://mutationgrid.com | 1-402-598-7782
>
>
>
>
>
> _______________________________________________
> Omaha-pm mailing list
> Omaha-pm at pm.org
> http://mail.pm.org/mailman/listinfo/omaha-pm
>



-- 
Andrew Sterling Hanenkamp
sterling at hanenkamp.com
785.370.4454
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/omaha-pm/attachments/20110116/898e2a2e/attachment.html>


More information about the Omaha-pm mailing list