2006-08-27 05:55:45 +02:00
|
|
|
#!/usr/bin/perl
|
|
|
|
# Discordian date support fnord ikiwiki.
|
|
|
|
package IkiWiki::Plugin::ddate;
|
2007-04-27 04:55:52 +02:00
|
|
|
|
|
|
|
use IkiWiki 2.00;
|
2006-08-27 05:55:45 +02:00
|
|
|
no warnings;
|
|
|
|
|
2008-12-17 21:22:16 +01:00
|
|
|
sub import {
|
2008-08-03 22:40:12 +02:00
|
|
|
hook(type => "getsetup", id => "ddate", call => \&getsetup);
|
2008-12-17 21:22:16 +01:00
|
|
|
}
|
2006-08-27 05:55:45 +02:00
|
|
|
|
2008-12-17 21:22:16 +01:00
|
|
|
sub getsetup {
|
2008-08-03 22:40:12 +02:00
|
|
|
return
|
|
|
|
plugin => {
|
|
|
|
safe => 1,
|
|
|
|
rebuild => 1,
|
|
|
|
},
|
2008-12-17 21:22:16 +01:00
|
|
|
}
|
2008-08-03 22:40:12 +02:00
|
|
|
|
2008-12-17 21:22:16 +01:00
|
|
|
sub IkiWiki::formattime ($;$) {
|
2006-08-27 05:55:45 +02:00
|
|
|
my $time=shift;
|
2008-01-29 05:48:27 +01:00
|
|
|
my $format=shift;
|
|
|
|
if (! defined $format) {
|
|
|
|
$format=$config{timeformat};
|
2008-09-09 01:40:23 +02:00
|
|
|
if ($format eq '%c') {
|
|
|
|
$format='on %A, the %e of %B, %Y. %N%nCelebrate %H';
|
|
|
|
}
|
2008-01-29 05:48:27 +01:00
|
|
|
}
|
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);
|
2008-01-29 05:48:27 +01:00
|
|
|
return $dd->strftime($format);
|
2008-12-17 21:22:16 +01:00
|
|
|
}
|
2006-08-27 05:55:45 +02:00
|
|
|
|
|
|
|
5
|