aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/relativedate.pm
diff options
context:
space:
mode:
authorJoey Hess <joey@kodama.kitenet.net>2008-10-19 19:13:40 -0400
committerJoey Hess <joey@kodama.kitenet.net>2008-10-19 19:21:44 -0400
commit2b569f99d9e7f1d4d30c7f3adde9729ff4d868cf (patch)
tree0b060526113707326edcf1c8fd47eda7e817102e /IkiWiki/Plugin/relativedate.pm
parentac8e8f5ad7387a815cb0eb1b0a662694c86f2439 (diff)
downloadikiwiki-2b569f99d9e7f1d4d30c7f3adde9729ff4d868cf.tar
ikiwiki-2b569f99d9e7f1d4d30c7f3adde9729ff4d868cf.tar.gz
fix relativedate timezone inclusion
The machine parseable date needs to include a timezone. Also, simplified the interface for date display.
Diffstat (limited to 'IkiWiki/Plugin/relativedate.pm')
-rw-r--r--IkiWiki/Plugin/relativedate.pm16
1 files changed, 16 insertions, 0 deletions
diff --git a/IkiWiki/Plugin/relativedate.pm b/IkiWiki/Plugin/relativedate.pm
index 2895f6d57..a918889d2 100644
--- a/IkiWiki/Plugin/relativedate.pm
+++ b/IkiWiki/Plugin/relativedate.pm
@@ -2,8 +2,11 @@
package IkiWiki::Plugin::relativedate;
use warnings;
+no warnings 'redefine';
use strict;
use IkiWiki 2.00;
+use POSIX;
+use Encode;
sub import { #{{{
add_underlay("javascript");
@@ -39,4 +42,17 @@ sub include_javascript ($;$) { #{{{
'" type="text/javascript" charset="utf-8"></script>';
} #}}}
+sub IkiWiki::displaytime ($;$) { #{{{
+ my $time=shift;
+ my $format=shift;
+
+ # This needs to be in a form that can be parsed by javascript.
+ # Being fairly human readable is also nice, as it will be exposed as the title
+ # if javascript is not available.
+ my $gmtime=decode_utf8(POSIX::strftime("%a, %d %b %Y %H:%M:%S %z", gmtime($time)));
+
+ return '<span class="date" title="'.$gmtime.'">'.
+ IkiWiki::formattime($time, $format).'</span>';
+} #}}}
+
1