Subject: | adding duration gives inconsistent values |
$dt = DateTime->new(year => 2008, month => 5, day => 1);
One would expect the following to give the last day of May,
$dt->add(months => 1, days => -1)
but DateTime returns 2008-05-30T00:00:00 instead.
Subject: | datetime.t |
#!/usr/bin/perl
use strict;
use Test::More tests => 2;
use DateTime ();
my $a = DateTime->new(year => 2008, month => 5, day => 1);
my $b = $a->clone->add(months => 1, hours => -24);
is($b->delta_days($a)->delta_days, 30, 'hours => -24 works on month boundary');
$b = $a->clone->add(months => 1, days => -1);
is($b->delta_days($a)->delta_days, 30, 'days => -1 works on month boundary');