Gossamer Forum
Home : Products : Links 2.0 : Discussions :

Re: [Andy] links.cfg date format help needed

Quote Reply
Re: [Andy] links.cfg date format help needed In reply to
Hi Andy,

Thanks for the reply,




Does it do it with all links? If so, have a look at this thread




Not sure if all links are but probably. What happen was that I used the back button on the browser after checking the rebuild, and it started to rebuild again, in rushed thinking I hit it again before it finished. After that I noticed I lost some directories and had a new one called 3. As you will notice the 3 is missing from the year at the begining of the error message:

Error Message : fatal error: invalid date format: 12-Jun-200 - parsed as (day: 12, month: 5, year: -1880). Reason: Can't handle date (0, 0, 0, 12, 5, -1880) at links.cfg line 198

I checked you forum link but not sure it can help, I checked the format and it seemed correct. It does show the correct date when building the category pages at the top, but shows the error above when building home, new, top links and such...

Here is what I have in the links.cfg file for the date format (Before the error I never edited it):





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!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";
}

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!January February March April May June July August September October November December!;
my @days = qw!Sunday Monday Tuesday Wednesday Thursday Friday Saturday!;
$year = $year + 1900;
return "$days[$dweek], $months[$mon] $day $year";
}

# -------------------------------------------------------------#




Seems correct...

Thanks for your time,
AuctionGuy
If you think Education is expensive, Try ignorance.
Subject Author Views Date
Thread links.cfg date format help needed AuctionGuy 4931 Jun 15, 2003, 3:58 PM
Thread Re: [AuctionGuy] links.cfg date format help needed
Andy 4804 Jun 16, 2003, 1:31 AM
Thread Re: [Andy] links.cfg date format help needed
AuctionGuy 4776 Jun 16, 2003, 11:31 AM
Thread Re: [AuctionGuy] links.cfg date format help needed
PerlFlunkie 4768 Jun 16, 2003, 2:43 PM
Thread Re: [PerlFlunkie] links.cfg date format help needed
AuctionGuy 4767 Jun 16, 2003, 7:34 PM
Thread Re: [AuctionGuy] links.cfg date format help needed
Andy 4785 Jun 17, 2003, 1:24 AM
Post Re: [Andy] links.cfg date format help needed
AuctionGuy 4752 Jun 17, 2003, 4:35 AM