]> sipb.mit.edu Git - ikiwiki.git/blob - IkiWiki/Plugin/date.pm
(no commit message)
[ikiwiki.git] / IkiWiki / Plugin / date.pm
1 #!/usr/bin/perl
2 package IkiWiki::Plugin::date;
3
4 use warnings;
5 use strict;
6 use IkiWiki 3.00;
7
8 sub import {
9         hook(type => "getsetup", id => "date", call => \&getsetup);
10         hook(type => "preprocess", id => "date", call => \&preprocess);
11 }
12
13 sub getsetup () {
14         return
15                 plugin => {
16                         safe => 1,
17                         rebuild => undef,
18                 },
19 }
20
21 sub preprocess (@) {
22         my $str=shift;
23
24         eval q{use Date::Parse};
25         error $@ if $@;
26         my $time = str2time($str);
27         if (! defined $time) {
28                 error("unable to parse $str");
29         }
30         return displaytime($time);
31 }
32
33 1