r50811 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50810‎ | r50811 | r50812 >
Date:07:14, 20 May 2009
Author:shinjiman
Status:ok (Comments)
Tags:
Comment:
* (bug 5755) Introduce {{CURRENTMONTH1}} and {{LOCALMONTH1}} to display the month number without the leading zero
* added {{CURRENTMONTH2}} and {{LOCALMONTH2}} as alias of {{CURRENTMONTH}} and {{LOCALMONTH}} for consistency with other magic words
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/MagicWord.php (modified) (history)
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/Parser.php
@@ -2341,6 +2341,7 @@
23422342 wfSuppressWarnings(); // E_STRICT system time bitching
23432343 $localTimestamp = date( 'YmdHis', $ts );
23442344 $localMonth = date( 'm', $ts );
 2345+ $localMonth1 = date( 'n', $ts );
23452346 $localMonthName = date( 'n', $ts );
23462347 $localDay = date( 'j', $ts );
23472348 $localDay2 = date( 'd', $ts );
@@ -2356,6 +2357,8 @@
23572358 switch ( $index ) {
23582359 case 'currentmonth':
23592360 return $this->mVarCache[$index] = $wgContLang->formatNum( gmdate( 'm', $ts ) );
 2361+ case 'currentmonth1':
 2362+ return $this->mVarCache[$index] = $wgContLang->formatNum( gmdate( 'n', $ts ) );
23602363 case 'currentmonthname':
23612364 return $this->mVarCache[$index] = $wgContLang->getMonthName( gmdate( 'n', $ts ) );
23622365 case 'currentmonthnamegen':
@@ -2368,6 +2371,8 @@
23692372 return $this->mVarCache[$index] = $wgContLang->formatNum( gmdate( 'd', $ts ) );
23702373 case 'localmonth':
23712374 return $this->mVarCache[$index] = $wgContLang->formatNum( $localMonth );
 2375+ case 'localmonth1':
 2376+ return $this->mVarCache[$index] = $wgContLang->formatNum( $localMonth1 );
23722377 case 'localmonthname':
23732378 return $this->mVarCache[$index] = $wgContLang->getMonthName( $localMonthName );
23742379 case 'localmonthnamegen':
Index: trunk/phase3/includes/MagicWord.php
@@ -36,6 +36,7 @@
3737 static public $mVariableIDsInitialised = false;
3838 static public $mVariableIDs = array(
3939 'currentmonth',
 40+ 'currentmonth1',
4041 'currentmonthname',
4142 'currentmonthnamegen',
4243 'currentmonthabbrev',
@@ -46,6 +47,7 @@
4748 'currenttime',
4849 'currenthour',
4950 'localmonth',
 51+ 'localmonth1',
5052 'localmonthname',
5153 'localmonthnamegen',
5254 'localmonthabbrev',
@@ -106,6 +108,7 @@
107109 /* Array of caching hints for ParserCache */
108110 static public $mCacheTTLs = array (
109111 'currentmonth' => 86400,
 112+ 'currentmonth1' => 86400,
110113 'currentmonthname' => 86400,
111114 'currentmonthnamegen' => 86400,
112115 'currentmonthabbrev' => 86400,
@@ -116,6 +119,7 @@
117120 'currenttime' => 3600,
118121 'currenthour' => 3600,
119122 'localmonth' => 86400,
 123+ 'localmonth1' => 86400,
120124 'localmonthname' => 86400,
121125 'localmonthnamegen' => 86400,
122126 'localmonthabbrev' => 86400,
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -210,7 +210,8 @@
211211 'toc' => array( 0, '__TOC__' ),
212212 'noeditsection' => array( 0, '__NOEDITSECTION__' ),
213213 'noheader' => array( 0, '__NOHEADER__' ),
214 - 'currentmonth' => array( 1, 'CURRENTMONTH' ),
 214+ 'currentmonth' => array( 1, 'CURRENTMONTH', 'CURRENTMONTH2' ),
 215+ 'currentmonth1' => array( 1, 'CURRENTMONTH1' ),
215216 'currentmonthname' => array( 1, 'CURRENTMONTHNAME' ),
216217 'currentmonthnamegen' => array( 1, 'CURRENTMONTHNAMEGEN' ),
217218 'currentmonthabbrev' => array( 1, 'CURRENTMONTHABBREV' ),
@@ -220,7 +221,8 @@
221222 'currentyear' => array( 1, 'CURRENTYEAR' ),
222223 'currenttime' => array( 1, 'CURRENTTIME' ),
223224 'currenthour' => array( 1, 'CURRENTHOUR' ),
224 - 'localmonth' => array( 1, 'LOCALMONTH' ),
 225+ 'localmonth' => array( 1, 'LOCALMONTH', 'LOCALMONTH2' ),
 226+ 'localmonth1' => array( 1, 'LOCALMONTH1' ),
225227 'localmonthname' => array( 1, 'LOCALMONTHNAME' ),
226228 'localmonthnamegen' => array( 1, 'LOCALMONTHNAMEGEN' ),
227229 'localmonthabbrev' => array( 1, 'LOCALMONTHABBREV' ),
Index: trunk/phase3/RELEASE-NOTES
@@ -63,6 +63,8 @@
6464 * Database: unionQueries function to be used for UNION sql construction, so
6565 it can be overloaded on DB abstraction level for DB specific functionality
6666 * (bug 18849) Implement Japanese and North Korean calendars
 67+* (bug 5755) Introduce {{CURRENTMONTH1}} and {{LOCALMONTH1}} to display the
 68+ month number without the leading zero
6769
6870 === Bug fixes in 1.16 ===
6971

Comments

#Comment by Tim Starling (talk | contribs)   05:49, 3 June 2009

Appending "1" is certainly a very compact and simple way to indicate the lack of a leading zero in the output. Maybe we should have more of that kind of naming in MediaWiki. But we have a long way to go before we can match the simplicity and ease of use of a package like w:LAPACK. A goal to strive for, I guess.

Status & tagging log