I have the following global to determine the age of a user:
my ($rec) = @_;
my $age;
my $day;
my $month;
my $year;
my $birthyear = $rec->{'BirthYear'};
my $birthmonth = $rec->{'BirthMonth'};
my $birthday = $rec->{'BirthDay'};
my $date = GT::Date::date_get();
($year, $month, $day) = split(/-/, $date);
$age = $year - $birthyear;
if ($month < $birthmonth) {
$age = $age - 1;
}
if ($month = $birthmonth) {
if ($day < $birthday) {
$age = $age - 1;
}
}
return $age;
}
It works great...if you are logged in. My question is two-fold:
1. If you are not logged in, the age shows the current year (e.g., 2008). I am using other globals that work properly without logging in so is there something here that could be fixed to work for guests?
2. If you are logged in, the age global displays the correct date in all places except when called in the link.html loop by modify.cgi. Then you get some odd string like 20080206008755. Back to the first part...is there something inherent in the above global that needs to be fixed to be more stable?
TIA,
Kevin
My Green Promise: To learn (and practice) as much as I can about living a sustainable life and then spreading the word.
What's your Green Promise?
Code:
sub { my ($rec) = @_;
my $age;
my $day;
my $month;
my $year;
my $birthyear = $rec->{'BirthYear'};
my $birthmonth = $rec->{'BirthMonth'};
my $birthday = $rec->{'BirthDay'};
my $date = GT::Date::date_get();
($year, $month, $day) = split(/-/, $date);
$age = $year - $birthyear;
if ($month < $birthmonth) {
$age = $age - 1;
}
if ($month = $birthmonth) {
if ($day < $birthday) {
$age = $age - 1;
}
}
return $age;
}
It works great...if you are logged in. My question is two-fold:
1. If you are not logged in, the age shows the current year (e.g., 2008). I am using other globals that work properly without logging in so is there something here that could be fixed to work for guests?
2. If you are logged in, the age global displays the correct date in all places except when called in the link.html loop by modify.cgi. Then you get some odd string like 20080206008755. Back to the first part...is there something inherent in the above global that needs to be fixed to be more stable?
TIA,
Kevin
My Green Promise: To learn (and practice) as much as I can about living a sustainable life and then spreading the word.
What's your Green Promise?