Well, I'm not expert of GT, but my input may also helps you a bit.
If I'm correct, you want 3 input values from template tags (dobyear, dobmonth, dobday), and you want as output how old is the user in years. Right?
If yes, then try out the first, and if it works, then the second optimized version.
The longer (not optimized) version of the
years_old global may look like:
Code:
sub {
Links::init_date(); # not sure if we really need this, as it was already initialized at cgi start
my $birthdate = shift; # we input a %yyyy%-%mm%-%dd% style date, so I don't set the date format
my $date = GT::Date::date_get();
my $days_difference = GT::Date::date_diff($date, $birthdate);
my $years_difference = INT($days_difference / 365);
return $years_difference;
}
A shorter optimized version of the
years_old global may look like:
Code:
sub {
Links::init_date(); # still not sure if we really need this, as it was already initialized at cgi start
return INT(GT::Date::date_diff(GT::Date::date_get(), shift) / 365);
}
You should call it with:
Code:
<%years_old($dobyear, $dobmonth, $dobday)%>
I had no time to try it out, but I think the logic is good.
If it doesn't work, I will help you out tomorrow, with another corrected global.
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...