]> sipb.mit.edu Git - ikiwiki.git/commitdiff
* Add --timeformat config option to allow changing how dates are displayed.
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Mon, 29 May 2006 05:09:43 +0000 (05:09 +0000)
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Mon, 29 May 2006 05:09:43 +0000 (05:09 +0000)
  Note that as a side effect, dates will now be displayed using the local
  timezone, not as GMT.

IkiWiki.pm
IkiWiki/Plugin/inline.pm
IkiWiki/Render.pm
debian/changelog
doc/ikiwiki.setup
doc/todo/done/strftime.mdwn [moved from doc/todo/strftime.mdwn with 100% similarity]
doc/usage.mdwn
ikiwiki

index 5424d435cee8fe037dd2bc38b3dd617050f253d8..ce9542f628ecbc055ecd331742e438ef3e6f56e9 100644 (file)
@@ -42,6 +42,7 @@ sub defaultconfig () { #{{{
        adminuser => undef,
        adminemail => undef,
        plugin => [qw{inline htmlscrubber}],
+       timeformat => '%c',
 } #}}}
            
 sub checkconfig () { #{{{
index 8b67bfa61c341e0f3ee4fbb5c409c4a7cc226e5b..6ecdf0d38989bc34e503607ed493520a83373dc5 100644 (file)
@@ -62,7 +62,7 @@ sub preprocess_inline (@) { #{{{
                $template->param(pagelink => htmllink($params{page}, $params{page}, $page));
                $template->param(content => get_inline_content($params{page}, $page))
                        if $params{archive} eq "no";
-               $template->param(ctime => scalar(gmtime($pagectime{$page})));
+               $template->param(ctime => displaytime($pagectime{$page}));
                $ret.=$template->output;
        }
        
index df08eb49c496aa31163e313c49451dab320258b0..c5922c933a7516b9a06476ce68855e9289664c97 100644 (file)
@@ -202,7 +202,7 @@ sub genpage ($$$) { #{{{
                parentlinks => [parentlinks($page)],
                content => $content,
                backlinks => [backlinks($page)],
-               mtime => scalar(gmtime($mtime)),
+               mtime => displaytime($mtime),
                styleurl => styleurl($page),
        );
        
@@ -223,6 +223,18 @@ sub check_overwrite ($$) { #{{{
        }
 } #}}}
 
+sub displaytime ($) { #{{{
+       my $time=shift;
+
+       if ($config{timeformat} eq '%c') {
+               return scalar(localtime($time)); # optimisation
+       }
+       else {
+               eval q{use POSIX};
+               return POSIX::strftime($config{timeformat}, localtime($time));
+       }
+} #}}}
+
 sub mtime ($) { #{{{
        my $file=shift;
        
index 10796a63acd0bbbcc1cebc05a3d32a49f0f73f04..f7a381e417dd0d6b8e11d503d673d39619fe03a0 100644 (file)
@@ -1,3 +1,11 @@
+ikiwiki (1.5) UNRELEASED; urgency=low
+
+  * Add --timeformat config option to allow changing how dates are displayed.
+    Note that as a side effect, dates will now be displayed using the local
+    timezone, not as GMT.
+
+ -- Joey Hess <joeyh@debian.org>  Mon, 29 May 2006 00:50:34 -0400
+
 ikiwiki (1.4) unstable; urgency=low
 
   * Tell HTML::Scrubber to treat "/" as a valid attribute which is its
index dee4ca1d57b24bf551974b382668dc1aed5dd2c3..cda524ae15dfc7671c1a1f2f95aa82cfabfc561a 100644 (file)
@@ -50,6 +50,8 @@ use IkiWiki::Setup::Standard {
        rss => 1,
        # Include discussion links on all pages?
        discussion => 1,
+       # Time format (for strftime)
+       #timeformat => '%c',
        # To change the enabled plugins, edit this list
        #plugin => [qw{pagecount inline brokenlinks search smiley
        #              htmlscrubber}],
index c0fab5232e5d5a0ec529d1f5db1c08e1f0c8a483..011cf53a2303537d7088ba00917be39953e9c4f9 100644 (file)
@@ -177,6 +177,11 @@ These options configure the wiki.
   Enables or disables "Discussion" links from being added to the header of
   every page. The links are enabled by default.
 
+* --timeformat format
+
+  Specify how to display the time or date. The format string is passed to the
+  strftime(3) function.
+
 * --verbose
 
   Be vebose about what is being done.
diff --git a/ikiwiki b/ikiwiki
index 3ea6b7aa05109ab47234a73eb161f023ee049c58..61b66374de58924d081218292289c777306e8e0d 100755 (executable)
--- a/ikiwiki
+++ b/ikiwiki
@@ -37,6 +37,7 @@ sub getconfig () { #{{{
                        "svnrepo" => \$config{svnrepo},
                        "svnpath" => \$config{svnpath},
                        "adminemail=s" => \$config{adminemail},
+                       "timeformat=s" => \$config{timeformat},
                        "exclude=s@" => sub {
                                $config{wiki_file_prune_regexp}=qr/$config{wiki_file_prune_regexp}|$_[1]/;
                        },