]> sipb.mit.edu Git - ikiwiki.git/blob - IkiWiki/Plugin/ddate.pm
escape wikilinks and preprocessor directives
[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 => "ddate", 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         my $format=shift;
22         if (! defined $format) {
23                 $format=$config{timeformat};
24         }
25         eval q{
26                 use DateTime;
27                 use DateTime::Calendar::Discordian;
28         };
29         if ($@) {
30                  return "some time or other ($@ -- hail Eris!)";
31         }
32         my $dt = DateTime->from_epoch(epoch => $time);
33         my $dd = DateTime::Calendar::Discordian->from_object(object => $dt);
34         return $dd->strftime($format);
35 } #}}}
36
37 5