Sanity check: Date::Manip versus summer time
am 25.01.2006 00:20:16 von unknownAll,
I have been using Date::Manip for convenient and flexible (though
heavyweight) time input, and I have discovered a behaviour that I find odd.
Given TZ=EST5EDT, it interprets 'jan 1 2006 noon' as 17:00 GMT. So far
so good.
But it also interprets 'jul 1 2006 noon' as 17:00 GMT (at least, when
run on Jan 24). Shouldn't it be 16:00 GMT?
If you give it TZ=EDT, 'jul 1 2006 noon' indeed comes out 16:00 GMT.
Am I crazy? Do I not know how to use the module? Did I miss something in
the docs? Do I have the wrong meaning for "is"? It seems arrogant to
assume I've found a bug this flagrant in a module that has been around
this long. No, I have not bothered Sullivan Beck with this yet.
We're talking Date::Manip v5.44, Perl 5.8.6, and Darwin (i.e. Mac OS X).
The details, including the test script, follow.
Thanks,
Tom Wyant
$ perl -v
This is perl, v5.8.6 built for darwin-2level
Copyright 1987-2004, Larry Wall
Perl may be copied only under the terms of either the Artistic License
or the GNU General Public License, which may be found in the Perl 5
source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'. If you have access to
the Internet, point your browser at http://www.perl.org/, the Perl Home
Page.
Wyants-White-iMac:~/Code/TLE/ECI tom 18:10:08
$ perl -MDate::Manip -le 'print Date::Manip->VERSION'
5.44
Wyants-White-iMac:~/Code/TLE/ECI tom 18:12:01
$ perl test.pl 'jan 1 2006 noon' TZ=EST5EDT
Date 'jan 1 2006 noon' parsed to 'Sun Jan 1 17:00:00 2006' GMT
Wyants-White-iMac:~/Code/TLE/ECI tom 18:10:29
$ perl test.pl 'jul 1 2006 noon' TZ=EST5EDT
Date 'jul 1 2006 noon' parsed to 'Sat Jul 1 17:00:00 2006' GMT
Wyants-White-iMac:~/Code/TLE/ECI tom 18:10:37
$ perl test.pl 'jul 1 2006 noon' TZ=EDT
Date 'jul 1 2006 noon' parsed to 'Sat Jul 1 16:00:00 2006' GMT
Wyants-White-iMac:~/Code/TLE/ECI tom 18:10:43
$
Here is test.pl:
#!/usr/local/bin/perl
use strict;
use warnings;
use Date::Manip;
use File::Basename;
use Getopt::Long;
my %opt;
GetOptions (\%opt, qw{final initial}) && @ARGV or die <
Test Date::Manip behaviour.
usage: perl @{[basename $0]} [options] date [initialization ...]
Where the date must acceptable to ParseDate, the initialization
strings must be acceptable to Date_Init, and the legal options
are:
-final = dump final output of Date_Init ()
-initial = dump initial output of Date_Init ()
eod
my $string = shift @ARGV;
my @initial = Date_Init (@ARGV);
$opt{initial} and
print "Initial configuration:\n", map {" $_\n"} @initial;
$opt{final} and
print "Final configuration:\n", map {" $_\n"} Date_Init ();
my $time = UnixDate ($string, '%s') or
die "Failed to parse '$string'.\n";
printf "Date '$string' parsed to '%s' GMT\n", scalar gmtime $time;