Click here to get back home

Sanity check: Date::Manip versus summer time

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Sanity check: Date::Manip versus summer time harryfmudd [AT] comcast [DOT] 01-24-2006
Get Chitika Premium
Posted by harryfmudd [AT] comcast [DOT] on January 24, 2006, 6:20 pm
Please log in for more thread options


All,

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 <<eod;

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 and
print "Initial configuration:\n", map {" $_\n"} @initial;
$opt 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;

Similar ThreadsPosted
RFC + sanity check, Tk::Text with Vi interface April 18, 2008, 7:29 pm
Use of uninitialized value in numeric lt (<) at /Date/Manip.pm September 16, 2008, 12:58 pm
military time with Date::Calc June 9, 2005, 1:09 am
Date and time--recommended module? November 8, 2006, 3:41 pm
A versus An (programatically) March 10, 2005, 9:24 am
SVN::Agent check out? August 10, 2008, 4:52 pm
check response with mod_perl October 22, 2004, 11:23 am
how to check for existenceof XML tags with XML::Simple? January 29, 2005, 12:45 pm
Net::SSH::Perl - Corrupted check bytes February 8, 2006, 9:33 am
perl xml check for element closure November 18, 2006, 9:26 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap