summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/date.pm
blob: 652e6df0a67ca75aba0e2eec9bdbbc3bb6c04e45 (plain)
  1. #!/usr/bin/perl
  2. package IkiWiki::Plugin::date;
  3. use warnings;
  4. use strict;
  5. use IkiWiki 3.00;
  6. sub import {
  7. hook(type => "getsetup", id => "date", call => \&getsetup);
  8. hook(type => "preprocess", id => "date", call => \&preprocess);
  9. }
  10. sub getsetup () {
  11. return
  12. plugin => {
  13. safe => 1,
  14. rebuild => undef,
  15. },
  16. }
  17. sub preprocess (@) {
  18. my $str=shift;
  19. eval q{use Date::Parse};
  20. error $@ if $@;
  21. my $time = str2time($str);
  22. if (! defined $time) {
  23. error("unable to parse $str");
  24. }
  25. return displaytime($time);
  26. }
  27. 1