develooper Front page | perl.datetime | Postings from March 2012

Re: Error with the leap year

Thread Previous | Thread Next
From:
Rich Bowen
Date:
March 2, 2012 03:06
Subject:
Re: Error with the leap year
Message ID:
0F67CFF1-2633-4EDD-830D-E9A302BBD90F@rcbowen.com



On Mar 1, 2012, at 17:14, <Jonathan.Peyser@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




Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About