look up avatar at comment post time
[ikiwiki] / 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                         section => "widget",
19                 },
20 }
21
22 sub preprocess (@) {
23         my $str=shift;
24
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 }
33
34 1