]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/relativedate.pm
use relativedate as the css class for dates that should display relative
[ikiwiki.git] / IkiWiki / Plugin / relativedate.pm
index a918889d24f8d6c2119329bd2fc8bd8ba45aaaf3..f4dba61a4e8e1511dff8cd9053c1c514e321be92 100644 (file)
@@ -12,6 +12,7 @@ sub import { #{{{
        add_underlay("javascript");
        hook(type => "getsetup", id => "relativedate", call => \&getsetup);
        hook(type => "format", id => "relativedate", call => \&format);
+       hook(type => "displaytime", id => "relativedate", call => \&display);
 } # }}}
 
 sub getsetup () { #{{{
@@ -42,16 +43,17 @@ sub include_javascript ($;$) { #{{{
                '" type="text/javascript" charset="utf-8"></script>';
 } #}}}
 
-sub IkiWiki::displaytime ($;$) { #{{{
+sub display ($;$) { #{{{
        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)));
+       # 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",
+                       localtime($time)));
 
-       return '<span class="date" title="'.$gmtime.'">'.
+       return '<span class="relativedate" title="'.$gmtime.'">'.
                IkiWiki::formattime($time, $format).'</span>';
 } #}}}