Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

mir (51)

mir
  xmltwig@gmail.com
http://www.xmltwig.com/

See http://www.xmltwig.com/mirod

Journal of mir (51)

Friday April 17, 2009
05:06 AM

DateTime tip

[ #38817 ]

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

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.