]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - IkiWiki/Plugin/date.pm
use one parameter form of file_pruned here too
[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                         section => "widget",
19                 },
20 }
22 sub preprocess (@) {
23         my $str=shift;
25         eval q{use Date::Parse};
26         error $@ if $@;
27         my $time = str2time($str);
28         if (! defined $time) {
29                 error("unable to parse $str");
30         }
31         return displaytime($time);
32 }
34 1