Gossamer Forum
Home : Products : Links 2.0 : Installation -- Unix :

invalid date format:

Quote Reply
invalid date format:
Hi

My host has now upgraded to Perl5.006 and I am recieving the dreaded:-

fatal error: invalid date format: 02-Aug-01 - parsed as (day: 2, month: 7, year: -1899). Reason: Can't handle date (0, 0, 0, 2, 7, -1899) at /home/.sites/122/site482/web/cgi-bin/links2/admin1/links.cfg line 173

I have searched the forum and found the fix provided by designerx in Jan:-

*********************************
Strangly enough the solution is absurdely simple. In your links.cfg script you would make one alteration... you simply add a 1 to the end of the $year

So for example on (my line 292) in links.cfg It would look like:
$time = &Time::Local::timelocal(0,0,0, $day, $months{$mon}, $year1);

instead of:
$time = &Time::Local::timelocal(0,0,0, $day, $months{$mon}, $year);

Just do this and it should solve all of your problems.
****************************************

however for some reason I am unable to get this to work. Could somebody confirm that the only alteration required is to alter :-

*************************************
sub date_to_unix {
# --------------------------------------------------------
# This routine must take your date format and return the time a la UNIX time().
# Some things to be careful about..
# timelocal does not like to be in array context, don't do my($time) = timelocal (..)
# int your values just in case to remove spaces, etc.
# catch the fatal error timelocal will generate if you have a bad date..
# don't forget that the month is indexed from 0!
#
my $date = shift; my $i;
my %months = map { $_ => $i++ } qw!Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec!;
my ($day, $mon, $year) = split(/-/, $date);

exists $months{$mon} or return undef;
$day = int($day); $year = $year - 1900;

require Time::Local;
my $time = 0;
eval {
$time = &Time::Local::timelocal(0,0,0, $day, $months{$mon}, $year);
};
if ($@) { die "invalid date format: $date - parsed as (day: $day, month: $months{$mon}, year: $year). Reason: $@"; }
return $time;
}
***************************************

to read

****************************************
sub date_to_unix {
# --------------------------------------------------------
# This routine must take your date format and return the time a la UNIX time().
# Some things to be careful about..
# timelocal does not like to be in array context, don't do my($time) = timelocal (..)
# int your values just in case to remove spaces, etc.
# catch the fatal error timelocal will generate if you have a bad date..
# don't forget that the month is indexed from 0!
#
my $date = shift; my $i;
my %months = map { $_ => $i++ } qw!Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec!;
my ($day, $mon, $year) = split(/-/, $date);

exists $months{$mon} or return undef;
$day = int($day); $year = $year - 1900;

require Time::Local;
my $time = 0;
eval {
$time = &Time::Local::timelocal(0,0,0, $day, $months{$mon}, $year1);
};
if ($@) { die "invalid date format: $date - parsed as (day: $day, month: $months{$mon}, year: $year). Reason: $@"; }
return $time;
}
***************************************

any assistance you can offer would be greatly appreciated!

Many thanks
Struggling! But getting there (I think?)
Quote Reply
Re: [Trying] invalid date format: In reply to
Search for Perl 5.006 in the Discussion or Customization forums...discussed before.
========================================
Buh Bye!

Cheers,
Me
Quote Reply
Re: [Trying] invalid date format: In reply to
Are you sure you mean 5.006, or do you infact mean 5.6 or 5.6.1?

Last edited by:

Paul: Aug 29, 2002, 2:36 AM