Subject: | TAI64 Epoch fails on parse_datetime( leap second ) |
If I feed TAI64 the tai-epoch-second of a leap second, it vomits. Here
I will set things up at the second before a leapsec and dump the date,
and the one two seconds later:
VERSION:
$ perl -e 'use DateTime; use DateTime::Format::Epoch::TAI64; print
STDERR "$DateTime::VERSION -- $DateTime::Format::Epoch::VERSION\n"; '
0.37 -- 0.10
GOOD:
$ perl -e 'use DateTime; use DateTime::Format::Epoch::TAI64; my $tai =
DateTime::Format::Epoch::TAI64->new();
my $dt = DateTime->new(year=>1972,month=>12, day=>31, hour=>23,
minute=>59, second=>59, time_zone=>'UTC'); print "$dt\t"; $leapbef =
$tai->format_datetime($dt); print $tai->parse_datetime($leapbef+0), " --
", $tai->parse_datetime($leapbef+2), "\n"; '
1972-12-31T23:59:59 1972-12-31T23:59:59 -- 1973-01-01T00:00:00
It dies if use the one-second-later (the actual leap second):
BAD:
$ perl -e 'use DateTime; use DateTime::Format::Epoch::TAI64; my $tai =
DateTime::Format::Epoch::TAI64->new();
my $dt = DateTime->new(year=>1972,month=>12, day=>31, hour=>23,
minute=>59, second=>59, time_zone=>'UTC'); print "$dt\t"; $leapbef =
$tai->format_datetime($dt); print $tai->parse_datetime($leapbef+0), " --
", $tai->parse_datetime($leapbef+1), "\n"; '
The 'hour' parameter ("24") to DateTime::new did not pass the 'is
between 0 and 23' callback
at
/usr/local/lib/perl5/site_perl/5.8.6/darwin-thread-multi-2level/DateTime.pm
line 173
DateTime::new('undef', 'hour', 24, 'minute', 0, 'second', 0,
'month', 12, ...) called at
/usr/local/lib/perl5/site_perl/5.8.6/darwin-thread-multi-2level/DateTime.pm
line 507
DateTime::from_object('undef', 'object',
'DateTime::Format::Epoch::_DateTime=HASH(0x1903160)') called at
/usr/local/lib/perl5/site_perl/DateTime/Format/Epoch.pm line 179
DateTime::Format::Epoch::parse_datetime('DateTime::Format::Epoch::TAI64=HASH(0x18fca9c)',
'Math::BigInt=HASH(0x19024b8)') called at
/usr/local/lib/perl5/site_perl/DateTime/Format/Epoch/TAI64.pm line 64
DateTime::Format::Epoch::TAI64::parse_datetime('DateTime::Format::Epoch::TAI64=HASH(0x18fca9c)',
'Math::BigInt=HASH(0x19024b8)') called at -e line 2
1972-12-31T23:59:59
It still dies if I try to enter the leap second directly:
BAD:
$ perl -e 'use DateTime; use DateTime::Format::Epoch::TAI64; my $tai =
DateTime::Format::Epoch::TAI64->new();
print $tai->parse_datetime("4611686018522082314"), " -- ",
$tai->parse_datetime("4611686018522082315"), "\n";'
The 'hour' parameter ("24") to DateTime::new did not pass the 'is
between 0 and 23' callback
at
/usr/local/lib/perl5/site_perl/5.8.6/darwin-thread-multi-2level/DateTime.pm
line 173
DateTime::new('undef', 'hour', 24, 'minute', 0, 'second', 0,
'month', 12, ...) called at
/usr/local/lib/perl5/site_perl/5.8.6/darwin-thread-multi-2level/DateTime.pm
line 507
DateTime::from_object('undef', 'object',
'DateTime::Format::Epoch::_DateTime=HASH(0x18f901c)') called at
/usr/local/lib/perl5/site_perl/DateTime/Format/Epoch.pm line 179
DateTime::Format::Epoch::parse_datetime('DateTime::Format::Epoch::TAI64=HASH(0x18fca9c)',
4611686018522082315) called at
/usr/local/lib/perl5/site_perl/DateTime/Format/Epoch/TAI64.pm line 64
DateTime::Format::Epoch::TAI64::parse_datetime('DateTime::Format::Epoch::TAI64=HASH(0x18fca9c)',
4611686018522082315) called at -e line 2
Also found while tracing this; I get different results if I feed in a
string vs. a large-ass integer. This may be some rookie error with 64
bitness or something, but I pass it along nonetheless.
CONFUSING:
$ perl -e 'use DateTime; use DateTime::Format::Epoch::TAI64; my $tai =
DateTime::Format::Epoch::TAI64->new();
print $tai->parse_datetime(4611686018522082314), " -- ",
$tai->parse_datetime("4611686018522082314"), "\n";'
1972-12-31T23:21:25 -- 1972-12-31T23:59:59
This is on an Intel Mac pro running 10.4.11; here's my Config dump:
Summary of my perl5 (revision 5 version 8 subversion 6) configuration:
Platform:
osname=darwin, osvers=8.0, archname=darwin-thread-multi-2level
uname='darwin b19.apple.com 8.0 darwin kernel version 8.3.0: mon oct
3 20:04:04 pdt 2005; root:xnu-792.6.22.obj~2release_ppc power macintosh
powerpc '
config_args='-ds -e -Dprefix=/usr -Dccflags=-g -pipe
-Dldflags=-Dman3ext=3pm -Duseithreads -Duseshrplib'
hint=recommended, useposix=true, d_sigaction=define
usethreads=define use5005threads=undef useithreads=define
usemultiplicity=define
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-g -pipe -fno-common -DPERL_DARWIN
-no-cpp-precomp -fno-strict-aliasing -I/usr/local/include',
optimize='-O3',
cppflags='-no-cpp-precomp -g -pipe -fno-common -DPERL_DARWIN
-no-cpp-precomp -fno-strict-aliasing -I/usr/local/include'
ccversion='', gccversion='4.0.1 (Apple Computer, Inc. build 5363)',
gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags ='-L/usr/local/lib'
libpth=/usr/local/lib /usr/lib
libs=-ldbm -ldl -lm -lc
perllibs=-ldl -lm -lc
libc=/usr/lib/libc.dylib, so=dylib, useshrplib=true,
libperl=libperl.dylib
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
cccdlflags=' ', lddlflags='-bundle -undefined dynamic_lookup
-L/usr/local/lib'
Characteristics of this binary (from libperl):
Compile-time options: MULTIPLICITY USE_ITHREADS USE_LARGE_FILES
PERL_IMPLICIT_CONTEXT
Locally applied patches:
23953 - fix for File::Path::rmtree CAN-2004-0452 security issue
33990 - fix for setuid perl security issues
SPRINTF0 - fixes for sprintf formatting issues - CVE-2005-3962
Built under darwin
Compiled at Nov 1 2006 17:07:31
%ENV:
PERL5LIB="/usr/local/lib/perl5/site_perl:/sw/lib/perl5:/sw/lib/perl5/darwin"
@INC:
/usr/local/lib/perl5/site_perl/5.8.6/darwin-thread-multi-2level
/usr/local/lib/perl5/site_perl/5.8.6
/usr/local/lib/perl5/site_perl
/sw/lib/perl5/5.8.6/darwin-thread-multi-2level
/sw/lib/perl5/5.8.6
/sw/lib/perl5/darwin-thread-multi-2level
/sw/lib/perl5
/sw/lib/perl5/darwin
/System/Library/Perl/5.8.6/darwin-thread-multi-2level
/System/Library/Perl/5.8.6
/Library/Perl/5.8.6/darwin-thread-multi-2level
/Library/Perl/5.8.6
/Library/Perl
/Network/Library/Perl/5.8.6/darwin-thread-multi-2level
/Network/Library/Perl/5.8.6
/Network/Library/Perl
/System/Library/Perl/Extras/5.8.6/darwin-thread-multi-2level
/System/Library/Perl/Extras/5.8.6
/Library/Perl/5.8.1/darwin-thread-multi-2level
/Library/Perl/5.8.1
.