]> sipb.mit.edu Git - ikiwiki.git/blob - doc/plugins/contrib/datetime_cmp.mdwn
(no commit message)
[ikiwiki.git] / doc / plugins / contrib / datetime_cmp.mdwn
1 [[!meta author="spalax"]]
2 [[!template id=plugin name=datetime_cmp author="[[Louis|spalax]]"]]
3 [[!tag type/pagespec]]
4
5 # Datetime_cmp
6
7 This plugin provides a family of
8 [pagespec](http://ikiwiki.info/ikiwiki/pagespec/) matching pages according to
9 creation or modification times.
10
11 It also sets the date of the next modification of the page on relevant date, so
12 that the page will be rebuilt if the condition changes.
13
14 ## List of functions
15
16 The list of functions is given by the following regexp:
17
18     [ct](date|time)_(lt|gt|leq|geq|eq|neq)_(abs|page|now|today)(|_delta)
19
20 where:
21
22   * `[ct]`: compare creation or modification time or date:
23     * `c`reation time;
24     * `m`odification time.
25   * `(date|time)`: compare full date and time, or only date (useful when time is irrelevant):
26     * `time`: compare full date and time;
27     * `date`: compare only date.
28   * `(lt|gt|leq|geq|eq|neq)`: operator of comparison:
29     * `lt`: less than;
30     * `gt`: greater than;
31     * `leq`: less or equal than;
32     * `geq`: greater or equal than;
33     * `eq`: equal;
34     * `neq`: not equal.
35   * `(abs|page|now|today)`: element to compare to:
36     * `abs`: absolute date or time (given in argument);
37     * `page`: other page (given in argument);
38     * `now`: date or time of compilation;
39     * `today`: same meaning as `now`.
40   * `(|_delta)`: used to add a time delta (to use comparisons such as *created at least two days after `some_page`*):
41     * *empty*: no delta;
42     * `_delta`: delta (given in argument).
43
44 ### Number of arguments
45
46 [[!table header=no data="""
47          | `now` `today`  | `page`            | `abs`
48 no delta | *no arguments* | `pagename`        | `date`
49 delta    | `delta`        | `pagename, delta` | `date, delta`
50 """]]
51
52 ### Format of arguments
53
54 * *date* or *time*: anything that can be recognized by perl [[str2time|http://search.cpan.org/~rse/lcwa-1.0.0/lib/lwp/lib/HTTP/Date.pm]] function, *without any comma*.
55 * *delta*: One of the following patterns:
56   * `Y-M-D`: positive date;
57   * `H:M:S`: positive time;
58   * `Y-M-D H:M:S`: positive date and time;
59   * Add `-` at the beginning of the string to make durations negative.
60 * several arguments: when two arguments are provided, they are passed as one string, which is then split according to the last comma.
61
62 ## Time zones
63
64 Key `timezone` in the setup file is used to define time zone. If not set, we
65 try to guess the local time zone.
66
67 ## Examples
68
69 ### Some functions
70
71 * `ctime_gt_page(foo)`: match pages created after page `foo`.
72 * `cdate_eq_today()`: match pages created the day the wiki is compiled.
73 * `mtime_eq_now()`: match pages modified the time the wiki is compiled (likely no page, since comparison is done up to the milisecond).
74 * `cdate_geq_page_delta(foo, 00-00-01)`: match pages created at least one day after page `foo`.
75 * `cdate_gt_page(foo)`: same as the previous one.
76 * `mdate_gt_today_delta(-00-01-00)`: match pages modified one month ago, or later (can be used to display recent changes).
77
78 ### Use case
79
80 It can be used to display a list of upcoming events.
81
82         \[[!inline pages="events/* and cdate_geq_today()" reverse=yes sorted=meta(date)]]
83
84 ## Code
85
86 Code and documentation this way: [[https://atelier.gresille.org/projects/gresille-ikiwiki/wiki/datetime_cmp]].