summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/ddate.pm
blob: 7382d4160cd84fe62f21daa366135dcabfde19f7 (plain)
  1. #!/usr/bin/perl
  2. # Discordian date support fnord ikiwiki.
  3. package IkiWiki::Plugin::ddate;
  4. use IkiWiki 2.00;
  5. no warnings;
  6. sub import { #{{{
  7. hook(type => "checkconfig", id => "skeleton", call => \&checkconfig);
  8. } # }}}
  9. sub checkconfig () { #{{{
  10. if (! defined $config{timeformat} ||
  11. $config{timeformat} eq '%c') {
  12. $config{timeformat}='on %A, the %e of %B, %Y. %N%nCelebrate %H';
  13. }
  14. } #}}}
  15. sub IkiWiki::displaytime ($;$) { #{{{
  16. my $time=shift;
  17. eval q{
  18. use DateTime;
  19. use DateTime::Calendar::Discordian;
  20. };
  21. if ($@) {
  22. return "some time or other ($@ -- hail Eris!)";
  23. }
  24. my $dt = DateTime->from_epoch(epoch => $time);
  25. my $dd = DateTime::Calendar::Discordian->from_object(object => $dt);
  26. return $dd->strftime($IkiWiki::config{timeformat});
  27. } #}}}
  28. 5