Subject: | day duration leads to invalid local time |
Date: | Sun, 11 Aug 2013 17:02:42 +0100 |
To: | bug-DateTime [...] rt.cpan.org |
From: | Zefram <zefram [...] fysh.org> |
With DateTime-1.03:
$dt0 = DateTime->new(year => 2013, month => 3, day => 30, hour => 1, time_zone => "Europe/London");
$dt1 = DateTime->new(year => 2013, month => 3, day => 31, hour => 2, time_zone => "Europe/London");
$dur = $dt1 - $dt0;
# $dur is 1 day
print $dt0 + $dur;
# => Invalid local time for date in time zone: Europe/London
As with the previous bug, this should be an easy case for duration
arithmetic, because the duration is being used additively to represent
the same calendar interval from which it was generated. $dur is
sane in describing the interval as 1 day; the two times are exactly 24
hours apart. However, adding that day onto $dt0 requires accounting for
the DST transition at the target time. ->add_duration is not in fact
doing what ->subtract_datetime assumed it would, and so the addition
and subtraction operations are mismatched.
-zefram