summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/ddate.pm
blob: 4e9d919a3bd182f88227a650616de48b94a2cf25 (plain)
  1. #!/usr/bin/perl
  2. # Discordian date support fnord ikiwiki.
  3. package IkiWiki::Plugin::ddate;
  4. use IkiWiki;
  5. use IkiWiki::Render; # so we can redefine it here
  6. no warnings;
  7. sub import { #{{{
  8. IkiWiki::hook(type => "checkconfig", id => "skeleton",
  9. call => \&checkconfig);
  10. } # }}}
  11. sub checkconfig () { #{{{
  12. if (! defined $IkiWiki::config{timeformat} ||
  13. $IkiWiki::config{timeformat} eq '%c') {
  14. $IkiWiki::config{timeformat}='on %{%A, the %e of %B%}, %Y. %N%nCelebrate %H';
  15. }
  16. } #}}}
  17. sub IkiWiki::displaytime ($) { #{{{
  18. my $time=shift;
  19. eval q{use POSIX};
  20. my $gregorian=POSIX::strftime("%d %m %Y", localtime($time));
  21. my $date=`ddate +'$IkiWiki::config{timeformat}' $gregorian`;
  22. chomp $date;
  23. if ($? || ! length $date) {
  24. return "some time or other (hail Eris!)";
  25. }
  26. return $date;
  27. } #}}}
  28. 5