While importing my Links2.0-DB there occure the following errors:
Import error: WARNING: Invalid date for link with ID 1002432. Link skipped.
Import error: WARNING: Invalid date `8-02-2001' encountered.
Import error: WARNING: Invalid date for link with ID 1002433. Link skipped.
Import error: WARNING: Invalid date `8-02-2001' encountered.
Import error: WARNING: Invalid date for link with ID 1002434. Link skipped.
Import error: WARNING: Invalid date `8-02-2001' encountered.
Import error: WARNING: Invalid date for link with ID 1002436. Link skipped.
Import error: WARNING: Invalid date `8-02-2001' encountered.
Import error: WARNING: Invalid date for link with ID 1002437. Link skipped.
... for every link (categoryies are imported well)
I have changed my date routines in links.cfg as followed and that works fine with Links2.0
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!01 02 03 04 05 06 07 08 09 10 11 12!;
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!01 02 03 04 05 06 07 08 09 10 11 12!;
$year = $year + 1900;
return "$day-$months[$mon]-$year";
}
Whats wrong?
Cheers,
Chris
Import error: WARNING: Invalid date for link with ID 1002432. Link skipped.
Import error: WARNING: Invalid date `8-02-2001' encountered.
Import error: WARNING: Invalid date for link with ID 1002433. Link skipped.
Import error: WARNING: Invalid date `8-02-2001' encountered.
Import error: WARNING: Invalid date for link with ID 1002434. Link skipped.
Import error: WARNING: Invalid date `8-02-2001' encountered.
Import error: WARNING: Invalid date for link with ID 1002436. Link skipped.
Import error: WARNING: Invalid date `8-02-2001' encountered.
Import error: WARNING: Invalid date for link with ID 1002437. Link skipped.
... for every link (categoryies are imported well)
I have changed my date routines in links.cfg as followed and that works fine with Links2.0
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!01 02 03 04 05 06 07 08 09 10 11 12!;
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!01 02 03 04 05 06 07 08 09 10 11 12!;
$year = $year + 1900;
return "$day-$months[$mon]-$year";
}
Whats wrong?
Cheers,
Chris