DateTime tip

mir on 2009-04-17T10:06:39

Note to self: add and subtract modify the calling object. Use clone if you just want to use the result.

So do not write this:

my $today      = DateTime->now;
my $yesterday  = $today->subtract( days => 1);# changes $today

Instead write this:

my $today      = DateTime->now;
my $yesterday  = $today->clone->subtract( days => 1); # note the 'clone' call


Consider Date::Tie

Ron Savage on 2009-04-18T01:52:31

Hi

Date::Tie is a beautiful module.

http://cpan.uwinnipeg.ca/htdocs/Date-Tie/Date/Tie.html

Re:Consider Date::Tie

mir on 2009-04-21T07:10:40

Thanks, I'll have to look at it closer, but still, it looks like you would need to clone a date object before doing any computation on it.

The module looks interesting though.