ikiwiki/IkiWiki/Plugin/ddate.pm

33 lines
758 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;
no warnings;
sub import { #{{{
hook(type => "checkconfig", id => "skeleton", call => \&checkconfig);
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
}
} #}}}
sub IkiWiki::displaytime ($) { #{{{
my $time=shift;
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($IkiWiki::config{timeformat});
2006-08-27 05:55:45 +02:00
} #}}}
5