View Issue Details

IDProjectCategoryView StatusLast Update
0000056WackoWikicorepublic2022-01-11 16:37
ReporterEoNy Assigned Toadministrator  
PrioritynormalSeverityfeatureReproducibilityN/A
Status resolvedResolutionfixed 
Product Version4.2 
Target Version5.0.betaFixed in Version5.0.beta 
Summary0000056: Configurable date and time formats
DescriptionThe default formatting for dates and times in WackoWiki is pretty much hard coded thru out the PHP code. The day.month.year and year-month-day formats aren't natural for us westerners to read.

I suggest adding some config options in $wackoLanguage
By adding some config options which allow the user to set the string passed into the date() function. It probably would be helpful for localization to other languages too.

I put up a patch on the wiki which worked with R4 RC1, but it could be implemented better than that.

updated link:http://www.sickheadgames.com/stuff/datetime.patch
http://wackowiki.org/doc/Dev/PatchesHacks/DateFormat
TagsNo tags attached.
Attached Files
datetime.patch (10,880 bytes)   
Index: wakka.php
===================================================================
--- wakka.php	(revision 383)
+++ wakka.php	(working copy)
@@ -130,6 +130,12 @@
   "db_collation" => 0,
   "rename_globalacl" => "Admins",
 
+  "date_format" => "Y-m-d",
+  "time_format" => "H:i:s",
+  "time_format_seconds" => "H:i",
+
+  "name_date_macro" => "%s /%s/",
+  "date_macro_format" => "d.m.Y H:i",
   );
 $wakkaDefaultConfig['aliases'] = array('Admins' => "",);
 
Index: themes/default/appearance/footer.php
===================================================================
--- themes/default/appearance/footer.php	(revision 383)
+++ themes/default/appearance/footer.php	(working copy)
@@ -16,7 +16,7 @@
 echo $this->HasAccess("write") ? "<a href=\"".$this->href("edit")."\" accesskey=\"E\" title=\"".$this->GetResourceValue("EditTip")."\">".$this->GetResourceValue("EditText")."</a> |\n" : "";
 
 // Revisions link
-echo $this->GetPageTime() ? "<a href=\"".$this->href("revisions")."\" title=\"".$this->GetResourceValue("RevisionTip")."\">".$this->GetPageTime()."</a> |\n" : "";
+echo $this->GetPageTime() ? "<a href=\"".$this->href("revisions")."\" title=\"".$this->GetResourceValue("RevisionTip")."\">".$this->GetPageTimeFormatted()."</a> |\n" : "";
 
 // If this page exists
 if ($this->page)
Index: themes/coffee/appearance/footer.php
===================================================================
--- themes/coffee/appearance/footer.php	(revision 383)
+++ themes/coffee/appearance/footer.php	(working copy)
@@ -2,7 +2,7 @@
 <div class="footer">
 <?php
 echo $this->HasAccess("write") ? "<a href=\"".$this->href("edit")."\" accesskey=\"E\" title=\"".$this->GetResourceValue("EditTip")."\">".$this->GetResourceValue("EditText")."</a> |\n" : "";
-echo $this->GetPageTime() ? "<a href=\"".$this->href("revisions")."\" title=\"".$this->GetResourceValue("RevisionTip")."\">".$this->GetPageTime()."</a> |\n" : "";
+echo $this->GetPageTime() ? "<a href=\"".$this->href("revisions")."\" title=\"".$this->GetResourceValue("RevisionTip")."\">".$this->GetPageTimeFormatted()."</a> |\n" : "";
 
 // if this page exists
   if ($this->page)
Index: themes/tabs/appearance/footer.php
===================================================================
--- themes/tabs/appearance/footer.php	(revision 383)
+++ themes/tabs/appearance/footer.php	(working copy)
@@ -8,7 +8,7 @@
         $this->method != "edit"
                        ) ?>
    <?php $this->EchoTab( $this->href("revisions"),  $this->GetResourceValue("RevisionTip"),
-        $this->GetPageTime() ? $this->GetPageTime() : "",
+        $this->GetPageTime() ? $this->GetPageTimeFormatted() : "",
         $this->method != "revisions"
                        ) ?>
 
Index: formatters/preformat.php
===================================================================
--- formatters/preformat.php	(revision 383)
+++ formatters/preformat.php	(working copy)
@@ -40,11 +40,11 @@
     }
     else if ($thing=="::@::")
     {                                    
-      return "((/".$wacko->GetUserName()." ".$wacko->GetUserName()."))"." ".date("/d.m.Y H:i/");
+      return sprintf($wacko->config["name_date_macro"],"((/".$wacko->GetUserName()." ".$wacko->GetUserName()."))",date($wacko->config["date_macro_format"]));
     }
     else if ($thing=="::+::")
     {                                    
-      return date("d.m.Y H:i");
+      return date($wacko->config["date_macro_format"]);
     }
     else if ((preg_match("/^(\[\[)(.+)(\]\])$/", $thing, $matches)) || 
              (preg_match("/^(\(\()(.+)(\)\))$/", $thing, $matches)) )
Index: classes/wacko.php
===================================================================
--- classes/wacko.php	(revision 383)
+++ classes/wacko.php	(working copy)
@@ -117,6 +117,8 @@
  function GetPageTag() { return $this->tag; }
  function GetPageSuperTag() { return $this->supertag; }
  function GetPageTime() { return $this->page["time"]; }
+ function GetTimeStringFormatted($time) { return date( $this->config["date_format"] ." ". $this->config["time_format_seconds"], strtotime( $time ) ); }
+ function GetPageTimeFormatted() { return $this->GetTimeStringFormatted( $this->page["time"] ); }
  function GetMethod() { return $this->method; }
  function GetConfigValue($name) { return isset( $this->config[$name] ) ? $this->config[$name] : ''; }
  function SetResource($lang) {$this->resource=&$this->resources[$lang];}
@@ -1952,7 +1954,7 @@
          $xml .= "<item>\n";
          $xml .= "<title>".$page["tag"]."</title>\n";
          $xml .= "<link>".$this->href("show", $page["tag"], "time=".urlencode($page["time"]))."</link>\n";
-         $xml .= "<description>".$page["time"]." by ".$page["user"]."</description>\n";
+         $xml .= "<description>".$this->GetTimeStringFormatted($page["time"])." by ".$page["user"]."</description>\n";
          $xml .= "</item>\n";
        }
      }
Index: actions/changes.php
===================================================================
--- actions/changes.php	(revision 383)
+++ actions/changes.php	(working copy)
@@ -30,12 +30,12 @@
       if ($day != $curday)
       {
         if ($curday) print("<br />\n");
-        print("<b>$day:</b><br />\n");
+        print("<b>".date($this->config["date_format"],strtotime($day)).":</b><br />\n");
         $curday = $day;
       }
 
       // print entry
-      print("&nbsp;&nbsp;&nbsp;<span class=\"dt\">".$time."</span> &mdash; (".
+      print("&nbsp;&nbsp;&nbsp;<span class=\"dt\">".date($this->config["time_format_seconds"], strtotime( $time ))."</span> &mdash; (".
             $this->ComposeLinkToPage($page["tag"], "revisions", $this->GetResourceValue("history"), 0).") ".
             $this->Link( "/".$page["tag"], "", $page["tag"] )." . . . . . . . . . . . . . . . . <small>".
             ($this->IsWikiName($page["user"])?$this->Link("/".$page["user"],"",$page["user"]):$page["user"])."</small><br />\n");
Index: handlers/page/diff.php
===================================================================
--- handlers/page/diff.php	(revision 383)
+++ handlers/page/diff.php	(working copy)
@@ -25,8 +25,8 @@
     $deleted = array_diff($bodyB, $bodyA);
 
     $output .= 
-      str_replace("%1", "<a href=\"".$this->href("", "", ($b!=-1?"time=".urlencode($pageA["time"]):""))."\">".$pageA["time"]."</a>", 
-      str_replace("%2", "<a href=\"".$this->href("", "", ($a!=-1?"time=".urlencode($pageB["time"]):""))."\">".$pageB["time"]."</a>",
+      str_replace("%1", "<a href=\"".$this->href("", "", ($b!=-1?"time=".urlencode($pageA["time"]):""))."\">".$this->GetTimeStringFormatted($pageA["time"])."</a>", 
+      str_replace("%2", "<a href=\"".$this->href("", "", ($a!=-1?"time=".urlencode($pageB["time"]):""))."\">".$this->GetTimeStringFormatted($pageB["time"])."</a>",
       str_replace("%3", $this->Link("/".$this->tag), 
       $this->GetResourceValue("Comparison"))))."<br />\n";
 
@@ -136,8 +136,8 @@
     $sideB->copy_until_ordinal($count_total_right,$output);
     $sideB->copy_whitespace($output);
     $out=$this->Format($output);
-    $out = str_replace("%1", "<a href=\"".$this->href("", "", "time=".urlencode($pageB["time"]))."\">".$pageB["time"]."</a>", 
-      str_replace("%2", "<a href=\"".$this->href("", "", "time=".urlencode($pageA["time"]))."\">".$pageA["time"]."</a>",
+    $out = str_replace("%1", "<a href=\"".$this->href("", "", "time=".urlencode($pageB["time"]))."\">".$this->GetTimeStringFormatted($pageB["time"])."</a>", 
+      str_replace("%2", "<a href=\"".$this->href("", "", "time=".urlencode($pageA["time"]))."\">".$this->GetTimeStringFormatted($pageA["time"])."</a>",
       str_replace("%3", $this->Link("/".$this->tag), 
       $this->GetResourceValue("Comparison"))))."<br />\n<br />\n".$out;
     print $out;
Index: handlers/page/revisions.xml.php
===================================================================
--- handlers/page/revisions.xml.php	(revision 383)
+++ handlers/page/revisions.xml.php	(working copy)
@@ -25,7 +25,7 @@
    if (($c <= $max) && $c>1)
    {
     $xml .= "<item>\n";
-    $xml .= "<title>".$page["time"]."</title>\n";
+    $xml .= "<title>".$this->GetTimeStringFormatted($page["time"])."</title>\n";
     $xml .= "<link>".$this->href("show").($this->GetConfigValue("rewrite_mode")?"?":"&amp;")."time=".urlencode($page["time"])."</link>\n";
     $_GET["a"] = $_GET["b"];
     $_GET["b"] = $page["id"];
Index: handlers/page/show.php
===================================================================
--- handlers/page/show.php	(revision 383)
+++ handlers/page/show.php	(working copy)
@@ -12,7 +12,7 @@
     // comment header?
     if ($this->page["comment_on"])
     {
-      print("<div class=\"commentinfo\">This is a comment on ".$this->ComposeLinkToPage($this->page["comment_on"], "", "", 0).", posted by ".($this->IsWikiName($this->page["user"])?$this->Link($this->page["user"]):$this->page["user"])." at ".$this->page["time"]."</div>");
+      print("<div class=\"commentinfo\">This is a comment on ".$this->ComposeLinkToPage($this->page["comment_on"], "", "", 0).", posted by ".($this->IsWikiName($this->page["user"])?$this->Link($this->page["user"]):$this->page["user"])." at ".$this->GetPageTimeFormatted()."</div>");
     }
 
     if ($this->page["latest"] == "N")
@@ -20,7 +20,7 @@
       print("<div class=\"revisioninfo\">".
         str_replace("%1",$this->href(), 
           str_replace("%2",$this->GetPageTag(),
-            str_replace("%3",$this->page["time"], 
+            str_replace("%3",$this->GetPageTimeFormatted(), 
               $this->GetResourceValue("Revision")))).".</div>");
     }
 
Index: handlers/page/revisions.php
===================================================================
--- handlers/page/revisions.php	(revision 383)
+++ handlers/page/revisions.php	(working copy)
@@ -32,7 +32,7 @@
         $output .= "<tr>";
         $output .= "<td><input type=\"radio\" name=\"a\" value=\"".($c==1?"-1":$page["id"])."\" ".($c == 1 ? "checked" : "")." /></td>";
         $output .= "<td><input type=\"radio\" name=\"b\" value=\"".($c==1?"-1":$page["id"])."\" ".($c == 2 ? "checked" : "")." /></td>";
-        $output .= "<td>&nbsp;<a href=\"".$this->href("show").($this->GetConfigValue("rewrite_mode")?"?":"&amp;")."time=".urlencode($page["time"])."\">".$page["time"]."</a></td>";
+        $output .= "<td>&nbsp;<a href=\"".$this->href("show").($this->GetConfigValue("rewrite_mode")?"?":"&amp;")."time=".urlencode($page["time"])."\">".$this->GetTimeStringFormatted($page["time"])."</a></td>";
         $output .= "<td>&nbsp;".$this->GetResourceValue("By")." ".($this->IsWikiName($page["user"])?$this->Link($page["user"]):$page["user"])."</td>";
         $output .= "</tr>\n";
       }
datetime.patch (10,880 bytes)   

Relationships

related to 0000149 resolvedadministrator Timezone different than server 
related to 0000341 assignedadministrator date and time formats dependent on user language 
child of 0000230 resolvedadministrator Administrative Interface 

Activities

EoNy

2007-08-31 15:57

manager   ~0000059

Last edited: 2022-01-11 16:37

tomspilman
11-02-2005 11:29

    If i submitted a new patch could it be considered for inclusion in R5?
 
tomspilman
07-07-2005 22:56

    I edited my wiki page and added a patch to this report which should work with SVN HEAD (aka r4.2). See http://wackowiki.org/doc/Dev/PatchesHacks/DateFormat for details.

administrator

2007-10-08 22:12

administrator   ~0000134

Last edited: 2008-01-10 16:46

another feature: user dependent time zone
-> 0000149

administrator

2009-10-24 09:47

administrator   ~0000720

Finally with rev781 - thanks Tom

Issue History

Date Modified Username Field Change
2007-08-31 15:56 EoNy New Issue
2007-08-31 15:56 EoNy File Added: datetimepatch.php
2007-08-31 15:56 EoNy Legacy => NEW
2007-08-31 15:57 EoNy Note Added: 0000059
2007-08-31 15:58 EoNy Description Updated
2007-08-31 21:02 administrator Legacy NEW => NPJ
2007-10-03 20:16 administrator Note Edited: 0000059
2007-10-03 20:18 administrator Note Edited: 0000059
2007-10-03 20:19 administrator Note Edited: 0000059
2007-10-08 18:10 administrator Description Updated
2007-10-08 18:11 administrator Description Updated
2007-10-08 18:12 administrator Note Edited: 0000059
2007-10-08 19:08 administrator Category Actions => Core
2007-10-08 22:12 administrator Note Added: 0000134
2007-10-25 04:34 administrator Assigned To => Tann San
2007-10-25 04:34 administrator Status new => assigned
2007-10-25 04:34 administrator Target Version => 5.0.0
2007-11-28 20:42 Tann San Assigned To Tann San =>
2007-12-24 17:24 administrator Status assigned => acknowledged
2007-12-24 17:24 administrator Target Version 5.0.0 => 7.0.x
2008-01-10 16:45 administrator Relationship added related to 0000149
2008-01-10 16:46 administrator Note Edited: 0000134
2008-04-10 18:32 administrator Description Updated
2008-04-10 18:33 administrator Note Edited: 0000059
2008-08-23 14:34 administrator Description Updated
2008-08-23 14:35 administrator Note Edited: 0000059
2008-09-21 16:08 Tann San Relationship added child of 0000230
2009-01-06 17:03 administrator Description Updated
2009-01-06 17:03 administrator Note Edited: 0000059
2009-03-15 22:06 administrator File Added: datetime.patch
2009-03-15 22:06 administrator File Deleted: datetimepatch.php
2009-10-24 08:43 administrator Assigned To => administrator
2009-10-24 08:43 administrator Target Version 7.0.x => 5.0.beta
2009-10-24 09:47 administrator Note Added: 0000720
2009-10-24 09:47 administrator Status acknowledged => resolved
2009-10-24 09:47 administrator Resolution open => fixed
2009-10-24 09:47 administrator Fixed in Version => 5.0.beta
2009-10-24 09:52 administrator Issue cloned: 0000341
2009-10-24 09:52 administrator Relationship added related to 0000341
2010-03-08 10:12 administrator Category Core => core
2011-05-31 21:24 administrator Build => R5.0.beta
2022-01-11 16:37 administrator Description Updated
2022-01-11 16:37 administrator Note Edited: 0000059