]> sipb.mit.edu Git - ikiwiki.git/blob - IkiWiki/Plugin/ddate.pm
* aggregate: Only save state if it was already loaded. This didn't used to
[ikiwiki.git] / IkiWiki / Plugin / ddate.pm
1 #!/usr/bin/perl
2 # Discordian date support fnord ikiwiki.
3 package IkiWiki::Plugin::ddate;
4
5 use IkiWiki 2.00;
6 no warnings;
7
8 sub import { #{{{
9         hook(type => "checkconfig", id => "skeleton", call => \&checkconfig);
10 } # }}}
11
12 sub checkconfig () { #{{{
13         if (! defined $config{timeformat} ||
14             $config{timeformat} eq '%c') {
15                 $config{timeformat}='on %A, the %e of %B, %Y. %N%nCelebrate %H';
16         }
17 } #}}}
18
19 sub IkiWiki::displaytime ($;$) { #{{{
20         my $time=shift;
21         eval q{
22                 use DateTime;
23                 use DateTime::Calendar::Discordian;
24         };
25         if ($@) {
26                  return "some time or other ($@ -- hail Eris!)";
27         }
28         my $dt = DateTime->from_epoch(epoch => $time);
29         my $dd = DateTime::Calendar::Discordian->from_object(object => $dt);
30         return $dd->strftime($IkiWiki::config{timeformat});
31 } #}}}
32
33 5