Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 78 lines (59 sloc) 1.914 kb
1748c01 @machack666 Improvements to the timed-display usertag
machack666 authored
1 UserTag timed-display Order start stop
25a3daa @perusiongreg Tag to allow for date specific display of text or html in pages.
perusiongreg authored
2 UserTag timed-display HasEndTag
1748c01 @machack666 Improvements to the timed-display usertag
machack666 authored
3 UserTag timed-display AddAttr 1
25a3daa @perusiongreg Tag to allow for date specific display of text or html in pages.
perusiongreg authored
4 UserTag timed-display Routine <<EOR
5 sub {
1748c01 @machack666 Improvements to the timed-display usertag
machack666 authored
6 my ($start, $stop, $opt, $body) = @_;
25a3daa @perusiongreg Tag to allow for date specific display of text or html in pages.
perusiongreg authored
7
1748c01 @machack666 Improvements to the timed-display usertag
machack666 authored
8 my $tv = $opt->{tv};
9 my $adjust = $opt->{adjust};
10 my $currtime = $tv && ($CGI->{$tv} || $Scratch->{$tv});
11
12 my $now = $Tag->convert_date({
13 fmt => '%Y%m%d%H%M',
14 body => $currtime,
15 adjust => $adjust,
16 });
25a3daa @perusiongreg Tag to allow for date specific display of text or html in pages.
perusiongreg authored
17 my $else = pull_else($body);
18
19 if (!$start){
20 $start = $now - 1;
21 }
22 if (!$stop){
23 $stop = '599900010000';#forever or at least after I die.
24 }
25
1748c01 @machack666 Improvements to the timed-display usertag
machack666 authored
26 $start = $Tag->convert_date({
27 fmt => '%Y%m%d%H%M',
28 body => $start,
29 });
30 $stop = $Tag->convert_date({
31 fmt => '%Y%m%d%H%M',
32 body => $stop,
33 });
25a3daa @perusiongreg Tag to allow for date specific display of text or html in pages.
perusiongreg authored
34 return $body if !$start;
35
1748c01 @machack666 Improvements to the timed-display usertag
machack666 authored
36 if ($start <= $now and $now <= $stop){
25a3daa @perusiongreg Tag to allow for date specific display of text or html in pages.
perusiongreg authored
37 return $body;
38 }
39 else {
40 return $else;
41 }
42 }
43
1748c01 @machack666 Improvements to the timed-display usertag
machack666 authored
44
25a3daa @perusiongreg Tag to allow for date specific display of text or html in pages.
perusiongreg authored
45 EOR
46
47 UserTag timed-display Documentation <<EOD
48
49 Purpose: To allow for date specific display of text or html in pages.
50
51 Usage:
52
53 [timed-display start=2007060608 stop=2007060612]
54 Some text/code to display between June 06, 2007 between 8am and Noon.
55 [/timed-display]
56
1748c01 @machack666 Improvements to the timed-display usertag
machack666 authored
57 For open ended display you can just specify a start date. To start
58 immediately and end on a specific date you can just specify a stop
59 date.
60
61 The start and stop date use the convert_date tag, so you can use any
62 format acceptable by that tag to specify your start and stop
63 dates. (See convert_date documentation for details.)
64
65 If the 'timevar' parameter is provided, instead of the current time
66 look first in the CGI and the Scratch variables with the provided name
67 for a date string to convert. This allows you to provide a way to
68 test this behavior outside of the wall-clock time and see the actual
69 behavior at a specific time.
25a3daa @perusiongreg Tag to allow for date specific display of text or html in pages.
perusiongreg authored
70
1748c01 @machack666 Improvements to the timed-display usertag
machack666 authored
71 You can also use the 'adjust' parameter, which will pass its argument
72 directly on to the convert_date calls; this can be used to localize
73 the timezone relative to the server time.
25a3daa @perusiongreg Tag to allow for date specific display of text or html in pages.
perusiongreg authored
74
75 EOD
76
77
Something went wrong with that request. Please try again.