LMPX.COM |
Home | Linux | Mysql | PHP | XML | ||
|
|
|||
From: Monty, James T Date: Fri Oct 3 14:49:56 2008 Subject: RE: leap seconds in DateTime
Zefram wrote: >Jim Monty wrote: >>Please explain this. I've always thought DateTime *does* handle leap >>seconds correctly. > >DateTime `knows', falsely, that there will be no more leap seconds after >the last one that it knows of. You can see this, for example, by asking >what is the UTC time N seconds after a given UTC time. Using DateTime >0.4304, for example, I get these correct results: > >$ perl -MDateTime -we '$dt=DateTime->new(year=>2008, month=>12, day=>30, >time_zone=>"UTC");$dt->add(seconds=>86400);print $dt,"\n"' >2008-12-31T00:00:00 >$ perl -MDateTime -we '$dt=DateTime->new(year=>2008, month=>12, day=>31, >time_zone=>"UTC");$dt->add(seconds=>86400);print $dt,"\n"' >2008-12-31T23:59:60 >$ > >... Uh-oh, I don't get the same results with DateTime 0.4304 and ActivePerl 5.8.8 on Windows XP: C:\>perldoc -m DateTime | grep "VERSION = " $VERSION = '0.4304'; C:\>perl -MDateTime -wle "my $dt = DateTime->new(year => 2008, month => 12, day => 30, time_zone => 'UTC'); $dt->add(seconds => (60 * 60 * 24) ); print $dt;" 2008-12-31T00:00:00 C:\>perl -MDateTime -wle "my $dt = DateTime->new(year => 2008, month => 12, day => 31, time_zone => 'UTC'); $dt->add(seconds => (60 * 60 * 24) ); print $dt;" 2009-01-01T00:00:00 C:\> [Time elapses.] Oh, I think I see the problem: C:\>perldoc -m DateTime::LeapSecond | grep "VERSION = " $VERSION = '0.05'; # last standalone distro was 0.03 C:\>perldoc -m DateTime::LeapSecond | egrep -B 3 -A 3 "^2006" 1996 Jan. 1 +1 1997 Jul. 1 +1 1999 Jan. 1 +1 2006 Jan. 1 +1 ) ); } C:\> [More time elapses.] I don't think this is a local problem. In other words, I see the proper entry for the next impending leap second (2009 Jan. 1 +1) missing from LeapSecond.pm on CPAN: http://search.cpan.org/src/DROLSKY/DateTime-0.4304/lib/DateTime/LeapSeco nd.pm It is, however, in leaptab.txt on CPAN: http://search.cpan.org/src/DROLSKY/DateTime-0.4304/leaptab.txt Hmm... -- Jim Monty (I apologize for the legal notice below.) <html> <body> <p>***********************************************************************</p> <p>The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. When addressed to our clients any opinions or advice contained in this email are subject to the terms and conditions expressed in the governing KPMG client engagement letter.</p> <p>***********************************************************************</p> </body> </html>
| Navigate in group perl.datetime at sever nntp.perl.org | |
| Previous | Next |
| © No Copyright You are free to use Anything |
Site Maintained by PHP Developer
Powered By PHP Consultants |