rbc has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

I am trying to use Date::Manip to deal with various date
formats.
#!/usr/bin/perl use Date::Manip; if ( !defined($ENV{'TZ'}) ) { print "Tz not set!\n"; $ENV{'TZ'} = "-0800"; } my $time_zone = $ENV{'TZ'}; my @strings = ( "1999/12/12", "02-03-01", "10-13-97", "2001-11-28" ); foreach $string ( @strings ) { my $date = &ParseDate( \$string ); print "string is $string date is $date \n"; }
And here's the output
Tz not set! string is 1999/12/12 date is 1999121200:00:00 string is 02-03-01 date is 2002030100:00:00 string is 10-13-97 date is string is 2001-11-28 date is 2001112800:00:00
Here's my questions:
1) why didn't Date::Manip read my mind and know that 02-03-01
should be "the thrid of February 2001"

2) what's wrong with 10-13-97 in the USA it should be
"the thirteenth of October 1997".

Replies are listed 'Best First'.
Re: Date::Manip question.
by zengargoyle (Deacon) on Mar 20, 2002 at 20:46 UTC

    perldoc Date::Manip will answer your question.

    The short version is:

                                                   ... All parts of
             the date can be separated by valid separators (space,
             "/", or ".").  The separator "-" may be used as long as
             it doesn't conflict with an ISO 8601 format, but this is
             discouraged since it is easy to overlook conflicts.  For
             example, the format MM/DD/YY is just fine, but MM-DD-YY
             does not work since it conflicts with YY-MM-DD.  To be
             safe, if "-" is used as a separator in a non-ISO format,
             they should be turned into "/" before calling the
             Date::Manip routines.  As with ISO 8601 formats, all
             separators are optional except for those given as a "/"
             in the list above.
    
Re: Date::Manip question.
by metadoktor (Hermit) on Mar 20, 2002 at 20:35 UTC
    I don't know why Date::Manip didn't do what you wanted it to but I've described some other useful date modules in this node.

    metadoktor

    "The doktor is in."