[ic] comparing dates
Mike Heins
mike at perusion.com
Wed Oct 1 21:39:43 EDT 2003
Quoting Grant (listbox at email.com):
>
> > > I've been using some ITL that I wrote to determine if one date
> > is a certain
> > > number of days after today's date. It seems to work OK except
> > one day when
> > > it was screwing up. I can't help wondering if there's some kind of
> > > functionality somewhere in IC or Perl that is more reliable.
> > Does anyone
> > > know of anything like that?
> >
> > I've used Date::Calc and Date::Manip from CPAN. Can't remember whether I
> > liked one over the other.
> >
> > Jon
>
> I think that's what I was looking for. Thanks Jon!
For something as simple as number of days, I think it is pretty easy
with $Tag->time(), too:
[calc]
my $compare = $CGI->{date};
my $numdays = $CGI->{days} || 5;
my $future = $Tag->time( {
body => '%Y%m%d%H%M%S',
adjust => "$numdays days",
});
if($compare ge $future) {
return "$compare IS $numdays days off (is > $future)";
}
else {
return "$compare NOT $numdays days off (not > $future)";
}
[/calc]
<p>
[loop list="3 4 5 6 7 8 9"]
[page href=@@MV_PAGE@@
form=|
days=[loop-code]
date=[time adjust="+5 days"]%Y%m%d%H%M%S[/time]</a>
|
]Check [loop-code] off from [time adjust="+5 days"/]</a><br>
[/loop]
</p>
If you want workdays, holidays, end-of-week, etc. then Date::Calc
can't be beat in my opinion.
--
Mike Heins
Perusion -- Expert Interchange Consulting http://www.perusion.com/
phone +1.513.523.7621 <mike at perusion.com>
Nature, to be commanded, must be obeyed. -- Francis Bacon
More information about the interchange-users
mailing list