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

Invalid date format..

Quote Reply
Invalid date format..
My Links have worked well for a time, but suddenly it's impossible to add new recoeds, and for some odd reasons it's not possible to get old link pages..it's if the db is erased, but it isn't.
Anyway: the error message I get when I try to add a new record is INVALID DATE FORMAT. Default for today was:
16-Okt-2000. I have tried all possible ways to get around that date problem, but no... Is there anybody out there with any possible solution? The odd thing is that links has worked well..until this...

Quote Reply
Re: Invalid date format.. In reply to
It looks like you made some changes to the date routines in the links.cfg. If the problem has suddenly happened without you doing anything to the script, then I would guess that your hosting company has upgraded their Perl package to 5.006, which has caused many problems in terms of how the new Time::Local handles date processing.

Regards,

Eliot Lee

Quote Reply
Re: Invalid date format.. In reply to
Thank you for your answere!
It seems like they really have done that upgrade. Do you think it might be any solution to override the Date parameters in Links.cfg? If so, do you know how to do that?


Quote Reply
Re: Invalid date format.. In reply to
HI,

If you are using the non-English mode and have changed the language type for the months;then you have to make sure that you have changed the following sections.

*****COPY OF LINKS.CFG***
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;
}

sub unix_to_date {
# --------------------------------------------------------
# This routine must take a unix time and return your date format
# A much simpler routine, just make sure your format isn't so complex that
# you can't get it back into unix time.
#
my $time = shift;
my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $tz) = localtime $time;
my @months = qw!Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec!;
$year = $year + 1900;
return "$day-$months[$mon]-$year";
}


Please backup your file before you modify the script.

Have a look at the month of October and make sure that you have changed it at both sections.

All the best Smile

Good night

ZZZzzzzzz

Joe


Quote Reply
Re: Invalid date format.. In reply to
Yeees!!!!
Thank you VERY much, this really did it!!!!!!!!
A big bottle of whiskey to you!!

Quote Reply
Re: Invalid date format.. In reply to
You are Welcome Smile.

Regards,

Joe