ikiwiki/IkiWiki/Plugin/ddate.pm

42 lines
807 B
Perl
Raw Normal View History

2006-08-27 05:55:45 +02:00
#!/usr/bin/perl
# Discordian date support fnord ikiwiki.
package IkiWiki::Plugin::ddate;
use IkiWiki 2.00;
2006-08-27 05:55:45 +02:00
no warnings;
sub import { #{{{
hook(type => "getsetup", id => "ddate", call => \&getsetup);
2006-08-27 05:55:45 +02:00
} # }}}
sub getsetup { #{{{
return
plugin => {
safe => 1,
rebuild => 1,
},
} #}}}
sub IkiWiki::formattime ($;$) { #{{{
2006-08-27 05:55:45 +02:00
my $time=shift;
my $format=shift;
if (! defined $format) {
$format=$config{timeformat};
if ($format eq '%c') {
$format='on %A, the %e of %B, %Y. %N%nCelebrate %H';
}
}
2006-09-15 00:28:04 +02:00
eval q{
use DateTime;
use DateTime::Calendar::Discordian;
};
if ($@) {
return "some time or other ($@ -- hail Eris!)";
2006-08-27 06:14:41 +02:00
}
2006-09-15 00:28:04 +02:00
my $dt = DateTime->from_epoch(epoch => $time);
my $dd = DateTime::Calendar::Discordian->from_object(object => $dt);
return $dd->strftime($format);
2006-08-27 05:55:45 +02:00
} #}}}
5