ikiwiki/IkiWiki/Plugin/ddate.pm

47 lines
969 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);
hook(type => "checkconfig", id => "ddate", call => \&checkconfig);
2006-08-27 05:55:45 +02:00
} # }}}
sub getsetup { #{{{
return
plugin => {
safe => 1,
rebuild => 1,
},
} #}}}
2006-08-27 05:55:45 +02:00
sub checkconfig () { #{{{
if (! defined $config{timeformat} ||
$config{timeformat} eq '%c') {
2006-09-15 00:28:04 +02:00
$config{timeformat}='on %A, the %e of %B, %Y. %N%nCelebrate %H';
2006-08-27 05:55:45 +02:00
}
} #}}}
2007-11-14 14:51:38 +01:00
sub IkiWiki::displaytime ($;$) { #{{{
2006-08-27 05:55:45 +02:00
my $time=shift;
my $format=shift;
if (! defined $format) {
$format=$config{timeformat};
}
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