Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Convert Date

Quote Reply
Convert Date
Hi,

Having a problem getting Glinks 3.0.3 to convert the date format from Links 2.0

which is 30-June-2005 to 2005-06-30 which is my date format for GLinks.


Can anyone see why this code is not working!!!

# Converts a date. Returns false if the date is invalid.
sub convert_date ($) {
my $in = shift;
my ($day, $mon, $year) = split /-/, $in, 3;
if ($year and $mon and $day) {
return sprintf("%0d-%0d-%0d", $year, $mon, $day);
}
else {
warning "Invalid date `$in' encountered.";
return;
}
}

I get something like this 2005-00-30 or 2020-00-30
Quote Reply
Re: [rascal] Convert Date In reply to
Try using GT::Date's conversion subroutine for that...

Code:
date_transform('30-June-2005', '%dd%-%mmm%-%yyyy%', '%yyyy%-%mm%-%dd%');

Check the docs for further info.

Philip
------------------
Limecat is not pleased.