[Date Index][Thread Index]
[Date Prev][Date Next][Thread Prev][Thread Next]
Re: How to define an \<expire\> tag\?
- From: nospam@thanx (Ralf S. Engelschall)
- Date: Sat, 24 Jan 1998 17:53:56 +0100 (MET)
In article <199801241542.QAA13556@en1.engelschall.com> you wrote:
> Hello Fritz Zaucker, in a previous mail you wrote:
>> --- WML input starts below ---
>> <title>Title of the page</title>
>> <h1>Header</h1>
>>
>> <expire 1999/12/31>
>>
>> Whatever is going onto the page ...
>> --- End of WML input file ---
>>
> | <define-tag expire>
> | <:{
> | use Date::Parse;
> | my $et = Date::Parse::str2time('%0');
> | my $ct = time();
> | print '<<main..' if ($et <= $ct);
> | }:>
> | </define-tag>
Hmmm... while this Date::Parse-based approach is powerful (because it
recognizes a lot of formats) I now was not really happy with it because
Date::Parse is not a standard Perl module. On the other hand because our
expire decision is done at _generation_ time and more then once per day a
cronjob will not regenerate a webpage to let this <expire> tag apply, your
yyyy-mm-dd format is all we need. And because this format is such simple we
can do a second try for an <expires> tag which runs out-of-the-box without the
need for 3rd party modules to be installed:
| <define-tag expires>
| <:{
| # parse yy-mm-dd format into (dd, mm, yyyy)
| my @et = reverse(split(/-/, '%0'));
| # parse localtime into (dd, mm, yyyy)
| my @ct = (localtime(time()))[3..5]; $ct[1] += 1; $ct[2] += 1900;
|
| # leave all standard locations
| # (and implicitly enter "null" location)
| # if already expired
| if ( $ct[0]+31*$ct[1]*395*$ct[2]
| >= $et[0]+31*$et[1]*395*$et[2]) {
| print '<<main..'
| }
| }:>
| </define-tag>
Isn't it a little bit better? ;_)
Perhaps someone of you makes it even better. At least the if-statement?
Greetings,
Ralf S. Engelschall
rse@engelschall.com
www.engelschall.com
______________________________________________________________________
Website META Language (WML) www.engelschall.com/sw/wml/
Official Support Mailing List sw-wml@engelschall.com
Automated List Manager majordomo@engelschall.com