Gossamer Forum
Home : Products : Links 2.0 : Discussions :

links.cfg date format help needed

Quote Reply
links.cfg date format help needed
Hi,

I get this error when using "Build".

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


Won't build Home or New Pages but will build Category... Tried looking at the links.cfg but I'm lost where the date format should be. Any help??

Thanks for your time,
AuctionGuy
If you think Education is expensive, Try ignorance.
Quote Reply
Re: [AuctionGuy] links.cfg date format help needed In reply to
Does it do it with all links? If so, have a look at this thread;

http://www.gossamer-threads.com/...date%20format;#18699

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
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.
Quote Reply
Re: [AuctionGuy] links.cfg date format help needed In reply to
If all you did was 'build,' without making any changes to the code, the try replacing your db file with the backups (try a couple of days old), then build again. Maybe hitting the back button, etc messed up your working db files.


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] links.cfg date format help needed In reply to
Hi Perljunkie,

Checked backups but they all include correct date. (no missing 3 in the year). The problem seems to originate from either the links.cfg or nph_build file as far as I can tell. Thanks for the idea tho.. Any other Ideas anyone?? Unsure
AuctionGuy
If you think Education is expensive, Try ignorance.
Quote Reply
Re: [AuctionGuy] links.cfg date format help needed In reply to
Can you paste a line out of your links.db? I'll try and write a simple Perl script that will repairs the links that have a missing digit.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] links.cfg date format help needed In reply to
Hi Andy,

After you mentioned the links.db I decided to take a second look... geuss what, found it. Must have got bleary eye'd after awhile the first time Blush Anyway it's all back to normal. Thanks for the clues PerlJunkie and Andy! Smile GT Forum comes through again!

Again Thanks Guys,
AuctionGuy
If you think Education is expensive, Try ignorance.