summaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/date.pm
blob: ea5c9a9c5dae9e29ef5ca73b6a066c495405f7b9 (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. section => "widget",
  16. },
  17. }
  18. sub preprocess (@) {
  19. my $str=shift;
  20. eval q{use Date::Parse};
  21. error $@ if $@;
  22. my $time = str2time($str);
  23. if (! defined $time) {
  24. error("unable to parse $str");
  25. }
  26. return displaytime($time);
  27. }
  28. 1