Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Invalid date when importing from Links 2.0

Quote Reply
Invalid date when importing from Links 2.0
Uh. Also have problem with date in some links.

My links.cfg (in Links 2.0) looks like this:
....
Code:
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";
}

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!Siječanj Veljača Ožujak Travanj Svibanj Lipanj Srpanj Kolovoz Rujan Listopad Studeni Prosinac!;
my @days = qw!Nedjelja Ponedjeljak Utorak Srijeda Četvrtak Petak Subota!;
$year = $year + 1900;
return "$days[$dweek], $months[$mon] $day $year";
}

How to change L2S2.pm to import good date?
(my format is dd-mm-yyyy)

Thanks.

UnReal Network
Quote Reply
Re: [deadroot] Invalid date when importing from Links 2.0 In reply to
convert_date function awaits this format: 08-Jan-2000
and returns this format: 2000-01-08
Your date format is: 08-01-2000

So you need to reverse it. In L2S2.pm, within the import() function, do the following changes.

Around line 510 replace this:
Code:
$date = convert_date($date) or warning("Invalid date for link with ID $id. Link skipped."),next;
to
Code:
# $date = convert_date($date) or warning("Invalid date for link with ID $id. Link skipped."),next;
my (@xdate) = split /-/, $in, 3;
$date = join "-", reverse @xdate;



Around line 619 replace this:

Code:
$date = convert_date($date) or warning("Invalid date `$date' for link with ID $id. Link skipped."),next;
to
Code:
#$date = convert_date($date) or warning("Invalid date `$date' for link with ID $id. Link skipped."),next;
my (@xdate) = split /-/, $in, 3;
$date = join "-", reverse @xdate;


Note, I did not try the code.
But logically it should work.

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [deadroot] Invalid date when importing from Links 2.0 In reply to
What problems are you having?

Is that date format the default Links2 format or have you changed it?

If it is the default format then Links SQL import handles this automatically.
Quote Reply
Re: [Paul] Invalid date when importing from Links 2.0 In reply to
Hi

Thank you for reply. Already talked with Jack Ong and managed to import it. But thanks.

Regards

UnReal Network
Quote Reply
Re: [deadroot] Invalid date when importing from Links 2.0 In reply to
Well, once you got help from others, you may at least post a short note, that you got the solution, so we should not waste our time... Crazy

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...
Quote Reply
Re: [webmaster33] Invalid date when importing from Links 2.0 In reply to
Oh. Ok. I'm sorry about that. Will do that next time.

I've posted a message and didn't get reply in few days and it was very urgent so I've asked Jack a help.

Know that's not excuse so again, really sorry.

Regards

UnReal Network
Quote Reply
Re: [deadroot] Invalid date when importing from Links 2.0 In reply to
No problem. Just I would like to avoid such cases.

Best regards,
Webmaster33


Paid Support
from Webmaster33. Expert in Perl programming & Gossamer Threads applications. (click here for prices)
Webmaster33's products (upd.2004.09.26) | Private message | Contact me | Was my post helpful? Donate my help...