[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
Re: [ic] comparing dates and numbers
Quoting Mstrshnds@aol.com (Mstrshnds@aol.com):
> I'm trying to compare a date in the userdb with todays day to determine if
> membership has expired. Here is the code, it always returns 0. I've been
> working on this all day with no luck, any help would be appreciated, Thanks.
>
> [seti check_expired]
> [perl]
> my $today_date = [tag time]%Y%m%d[/tag];
> my $club_date = [value club_current];
> if ($today_date - $club_date > 0) {
> return 1;
> } else {
> return;
> }
> [/perl]
> [/seti]
Change your [perl][/perl] to [calc][/calc] and it will/should work.
The [perl] tag doesn't interpolate contained tags by default, and
[calc] does.
More efficient would be:
[calc]
my $today_date = q{[time]%Y%m%d[/time]};
my $club_date = $Values->{club_current};
delete $Scratch->{check_expired};
if ($today_date lt $club_date) {
$Scratch->{check_expired} = 1;
}
[/calc]
No extra [seti] and fewer tag parses.
There are also expiration features built into the userdb, and those can
be found in the docs.
--
Red Hat, Inc., 3005 Nichols Rd., Hamilton, OH 45013
phone +1.513.523.7621 <mheins@redhat.com>
Being against torture ought to be sort of a bipartisan thing.
-- Karl Lehenbauer