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

Invalid date format

Quote Reply
Invalid date format
In links.cfg I have changed the date format in the following format:

# Date Routines
# --------------------------------------------------------
# Your date format can be whatever you like, as long as the following
# two functions are defined &date_to_unix and &unix_to_date:
# The default is dd-mmm-yyyy.

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!januarja februarja marca aprila maja junija julija avgusta septembra oktobra novembra decemb
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!januarja februarja marca aprila maja junija julija avgusta septembra oktobra novembra decembra!;
$year = $year + 1900;
return "$day. $months[$mon] $year";
}

sub long_date {
# --------------------------------------------------------
# This routine is for printing a nicer date format on the what's new page. It should
# take in a date in your current format and return a new one.
my $time = shift;
$time = &date_to_unix ($time);
my ($sec, $min, $hour, $day, $mon, $year, $dweek, $dyear, $tz) = localtime $time;
my @months = qw!januar februar marec april maj junij julij avgust september oktober november december!;
my @days = qw!Nedelja Ponedeljek Torek Sreda Cetrtek Petek Sobota!;
$year = $year + 1900;
return "$days[$dweek], $day. $months[$mon] $year";
}



When I add a new link, it appears:

Date (Invalid date Format).

What must I change, Bobsie?
Quote Reply
Re: Invalid date format In reply to
 
Quote:
Date (Invalid date Format)

Is that all you got? There should have been more to that error message; some other information as to what was returned. It is hard to decipher what is going on without the complete error message and all information returned with it.
Quote Reply
Re: Invalid date format In reply to
Yes, that's all I have got, but I fixed that problem...
But...the default date is "dd-mmm-yyyy".
How can I change it in f.e. "dd. mmm yyyy"?

I tryed to do this withought no success...it is possible to change this?
Quote Reply
Re: Invalid date format In reply to
Zevsek!

How did you fix that, because I am suddenly getting the same problem, although it worked before ???

Did not change anything in nph-build.cgi or the date routines ...
Quote Reply
Re: Invalid date format In reply to
It is probably a problem with your ISP/Hosting Company upgrading their Perl package to 5.6, which includes an upgraded Local.pm module.

Contact your hosting company for assistance.

Regards,

------------------
Eliot Lee....
Former Handle: Eliot
Anthro TECH, L.L.C
anthrotech.com
* Check Resource Center
* Search Forums
* Thinking out of the box (codes) is not only fun, but effective.