On Fri, Mar 2, 2012 at 10:06 PM, Rich Bowen <rbo...@rcbowen.com> wrote:
> > > > On Mar 1, 2012, at 17:14, <jonathan.pey...@ubs.com> wrote: > > > If the date for $dt is 20120229, the following produces an error! > > > > $dt->set_year($dt1->year + 1); > > > > Invalid day of month (day = 29 - month = 2) > > at /sbcimp/run/pd/cpan/5.8.8-2006.03/lib/DateTime.pm line 170 > > DateTime::new('undef', 'hour', 0, 'second', 0, 'month', 2, 'locale', > 'DateTime::Locale::en_US=HASH(0x8e15400)', ...) called at > /sbcimp/run/pd/cpan/\ > > > > 5.8.8-2006.03/lib/DateTime.pm line 1507 > > DateTime::set('undef', 'year', 2013) called at > /sbcimp/run/pd/cpan/5.8.8-2006.03/lib/DateTime.pm line 1514 > > > Yeah. That was the subject of days of discussion as to what the right > thing to do here was. Leap years are hard. This is what we decided was the > right thing to do here. > > -- > Rich Bowen, mobile edition The problem is pretty much identical to adding 1 month to a month with more days than the next (i.e. any month with 31 days except January and July). The behaviour should be the same, which it is. Regards Myfanwy White