summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/ddate.pm
blob: bb77ce59f267a5c9e541a1f42f88d6eca0eee4f1 (plain)
  1. #!/usr/bin/perl
  2. # Discordian date support fnord ikiwiki.
  3. package IkiWiki::Plugin::ddate;
  4. use IkiWiki 3.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::formattime ($;$) {
  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