aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki.pm
diff options
context:
space:
mode:
authorJoey Hess <joey@kitenet.net>2010-05-02 13:44:13 -0400
committerJoey Hess <joey@kitenet.net>2010-05-02 13:44:13 -0400
commit970373548fda77223ebbeb6aadbdbe4884b67cef (patch)
tree96bff9d98712ea9a0171ebe6620edea46b7f0e7d /IkiWiki.pm
parentf9e41d19b77f677a58bb22e1db47627cf9faa57f (diff)
downloadikiwiki-970373548fda77223ebbeb6aadbdbe4884b67cef.tar
ikiwiki-970373548fda77223ebbeb6aadbdbe4884b67cef.tar.gz
Add parameter to displaytime to specify that it is a pubdate, and in html5 mode, use time tag.
Diffstat (limited to 'IkiWiki.pm')
-rw-r--r--IkiWiki.pm22
1 files changed, 20 insertions, 2 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm
index ed57710bb..c428de77f 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -998,10 +998,18 @@ sub abs2rel ($$) {
return $ret;
}
-sub displaytime ($;$) {
+sub displaytime ($;$$) {
# Plugins can override this function to mark up the time to
# display.
- return '<span class="date">'.formattime(@_).'</span>';
+ my $time=formattime($_[0], $_[1]);
+ if ($config{html5}) {
+ return '<time datetime="'.date_3339($_[0]).'"'.
+ ($_[2] ? ' pubdate' : '').
+ '>'.$time.'</time>';
+ }
+ else {
+ return '<span class="date">'.$time.'</span>';
+ }
}
sub formattime ($;$) {
@@ -1017,6 +1025,16 @@ sub formattime ($;$) {
return decode_utf8(POSIX::strftime($format, localtime($time)));
}
+sub date_3339 ($) {
+ my $time=shift;
+
+ my $lc_time=POSIX::setlocale(&POSIX::LC_TIME);
+ POSIX::setlocale(&POSIX::LC_TIME, "C");
+ my $ret=POSIX::strftime("%Y-%m-%dT%H:%M:%SZ", gmtime($time));
+ POSIX::setlocale(&POSIX::LC_TIME, $lc_time);
+ return $ret;
+}
+
sub beautify_urlpath ($) {
my $url=shift;