[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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



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@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@mutationgrid.com | http://mutationgrid.com | 1-402-598-7782





_______________________________________________
Omaha-pm mailing list
Omaha-pm@pm.org
http://mail.pm.org/mailman/listinfo/omaha-pm



--
Andrew Sterling Hanenkamp
sterling@hanenkamp.com
785.370.4454