]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - IkiWiki/Plugin/date.pm
(no commit message)
[git.ikiwiki.info.git] / IkiWiki / Plugin / date.pm
1 #!/usr/bin/perl
2 package IkiWiki::Plugin::date;
4 use warnings;
5 use strict;
6 use IkiWiki 3.00;
8 sub import {
9         hook(type => "getsetup", id => "date", call => \&getsetup);
10         hook(type => "preprocess", id => "date", call => \&preprocess);
11 }
13 sub getsetup () {
14         return
15                 plugin => {
16                         safe => 1,
17                         rebuild => undef,
18                 },
19 }
21 sub preprocess (@) {
22         my $str=shift;
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 }
33 1