[Home]WikiBugs/NumericDatesNeedZeroPadding

UseModWiki | WikiBugs | RecentChanges | Preferences

Added in 1.0.5 -- MarkusLude

Background

I'm using UseModWiki 1.0.4 on a Swedish site, and have opted to enable $NumberDates? and disable $UseAmPm. To state a page revision completed this morning, my Wiki might have printed:

Last edited 2009-3-9 8:09 by ...

Whether it's a bug or not, I do not like that notation, but prefer:

Last edited 2009-03-09 08:09 by ...

The latter also complies (almost) with the ISO 8601 standard.

Patch

Below please find a diff that shows the simple changes I made to the CalcDay and CalcTime? subroutines to implement appropriate zero padding (altered indenting disregarded).
--GunnarH


--- usemod-1.0.4/wiki.pl        2007-11-30 14:48:11.000000000 -0500
+++ wiki.pl     2009-03-09 15:31:34.000000000 -0400
@@ -3042,7 +3042,7 @@
   $ts += $TimeZoneOffset;
   my ($sec, $min, $hour, $mday, $mon, $year) = localtime($ts);
   if ($NumberDates) {
-    return ($year + 1900) . '-' . ($mon+1) . '-' . $mday;
+    return sprintf '%d-%02d-%02d', $year+1900, $mon+1, $mday;
   }
   return ("January", "February", "March", "April", "May", "June",
           "July", "August", "September", "October", "November",
@@ -3059,15 +3059,15 @@
   if (($TimeZoneOffset == 0) && ($ScriptTZ ne "")) {
     $mytz = " " . $ScriptTZ;
   }
-  $ampm = "";
-  if ($UseAmPm) {
+  unless ($UseAmPm) {
+    return sprintf "%02d:%02d$mytz", $hour, $min;
+  }
     $ampm = " am";
     if ($hour > 11) {
       $ampm = " pm";
       $hour = $hour - 12;
     }
     $hour = 12   if ($hour == 0);
-  }
   $min = "0" . $min   if ($min<10);
   return $hour . ":" . $min . $ampm . $mytz;
 }

UseModWiki | WikiBugs | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited May 25, 2009 9:46 pm by MarkusLude (diff)
Search: