diff options
author | Jonas Smedegaard <dr@jones.dk> | 2010-08-27 10:01:58 +0200 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2010-08-27 10:01:58 +0200 |
commit | f398ad035b973608d380c9939ea845d8e2a0cdc2 (patch) | |
tree | 1ba1a0c94e375ab8ed609eaa57a542c6b87de5a8 /IkiWiki/Plugin/date.pm | |
parent | 958e5735c946263a111420fe47abe58782581e8c (diff) | |
parent | 6d213a0c739d5b34357b01a616f99197eeba6ad9 (diff) |
Merge branch 'master' of git://git.ikiwiki.info
Diffstat (limited to 'IkiWiki/Plugin/date.pm')
-rw-r--r-- | IkiWiki/Plugin/date.pm | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/IkiWiki/Plugin/date.pm b/IkiWiki/Plugin/date.pm new file mode 100644 index 000000000..ea5c9a9c5 --- /dev/null +++ b/IkiWiki/Plugin/date.pm @@ -0,0 +1,34 @@ +#!/usr/bin/perl +package IkiWiki::Plugin::date; + +use warnings; +use strict; +use IkiWiki 3.00; + +sub import { + hook(type => "getsetup", id => "date", call => \&getsetup); + hook(type => "preprocess", id => "date", call => \&preprocess); +} + +sub getsetup () { + return + plugin => { + safe => 1, + rebuild => undef, + section => "widget", + }, +} + +sub preprocess (@) { + my $str=shift; + + eval q{use Date::Parse}; + error $@ if $@; + my $time = str2time($str); + if (! defined $time) { + error("unable to parse $str"); + } + return displaytime($time); +} + +1 |