summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/ddate.pm
blob: 6c36de0a6b120b6047c44cca610bcd5e80333c29 (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 => "getsetup", id => "ddate", call => \&getsetup);
  8. } # }}}
  9. sub getsetup { #{{{
  10. return
  11. plugin => {
  12. safe => 1,
  13. rebuild => 1,
  14. },
  15. } #}}}
  16. sub IkiWiki::displaytime ($;$) { #{{{
  17. my $time=shift;
  18. my $format=shift;
  19. if (! defined $format) {
  20. $format=$config{timeformat};
  21. if ($format eq '%c') {
  22. $format='on %A, the %e of %B, %Y. %N%nCelebrate %H';
  23. }
  24. }
  25. eval q{
  26. use DateTime;
  27. use DateTime::Calendar::Discordian;
  28. };
  29. if ($@) {
  30. return "some time or other ($@ -- hail Eris!)";
  31. }
  32. my $dt = DateTime->from_epoch(epoch => $time);
  33. my $dd = DateTime::Calendar::Discordian->from_object(object => $dt);
  34. return $dd->strftime($format);
  35. } #}}}
  36. 5