r50811 - Code Review

From MediaWiki.org

Jump to: navigation, search
Repository:MediaWiki
Revision:r50810 | r50811 (on ViewVC) | 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:

Diff [purge]

Index: trunk/phase3/includes/parser/Parser.php
===================================================================
--- trunk/phase3/includes/parser/Parser.php	(revision 50810)
+++ trunk/phase3/includes/parser/Parser.php	(revision 50811)
@@ -2341,6 +2341,7 @@
 		wfSuppressWarnings(); // E_STRICT system time bitching
 		$localTimestamp = date( 'YmdHis', $ts );
 		$localMonth = date( 'm', $ts );
+		$localMonth1 = date( 'n', $ts );
 		$localMonthName = date( 'n', $ts );
 		$localDay = date( 'j', $ts );
 		$localDay2 = date( 'd', $ts );
@@ -2356,6 +2357,8 @@
 		switch ( $index ) {
 			case 'currentmonth':
 				return $this->mVarCache[$index] = $wgContLang->formatNum( gmdate( 'm', $ts ) );
+			case 'currentmonth1':
+				return $this->mVarCache[$index] = $wgContLang->formatNum( gmdate( 'n', $ts ) );
 			case 'currentmonthname':
 				return $this->mVarCache[$index] = $wgContLang->getMonthName( gmdate( 'n', $ts ) );
 			case 'currentmonthnamegen':
@@ -2368,6 +2371,8 @@
 				return $this->mVarCache[$index] = $wgContLang->formatNum( gmdate( 'd', $ts ) );
 			case 'localmonth':
 				return $this->mVarCache[$index] = $wgContLang->formatNum( $localMonth );
+			case 'localmonth1':
+				return $this->mVarCache[$index] = $wgContLang->formatNum( $localMonth1 );
 			case 'localmonthname':
 				return $this->mVarCache[$index] = $wgContLang->getMonthName( $localMonthName );
 			case 'localmonthnamegen':
Index: trunk/phase3/includes/MagicWord.php
===================================================================
--- trunk/phase3/includes/MagicWord.php	(revision 50810)
+++ trunk/phase3/includes/MagicWord.php	(revision 50811)
@@ -36,6 +36,7 @@
 	static public $mVariableIDsInitialised = false;
 	static public $mVariableIDs = array(
 		'currentmonth',
+		'currentmonth1',
 		'currentmonthname',
 		'currentmonthnamegen',
 		'currentmonthabbrev',
@@ -46,6 +47,7 @@
 		'currenttime',
 		'currenthour',
 		'localmonth',
+		'localmonth1',
 		'localmonthname',
 		'localmonthnamegen',
 		'localmonthabbrev',
@@ -106,6 +108,7 @@
 	/* Array of caching hints for ParserCache */
 	static public $mCacheTTLs = array (
 		'currentmonth' => 86400,
+		'currentmonth1' => 86400,
 		'currentmonthname' => 86400,
 		'currentmonthnamegen' => 86400,
 		'currentmonthabbrev' => 86400,
@@ -116,6 +119,7 @@
 		'currenttime' => 3600,
 		'currenthour' => 3600,
 		'localmonth' => 86400,
+		'localmonth1' => 86400,
 		'localmonthname' => 86400,
 		'localmonthnamegen' => 86400,
 		'localmonthabbrev' => 86400,
Index: trunk/phase3/languages/messages/MessagesEn.php
===================================================================
--- trunk/phase3/languages/messages/MessagesEn.php	(revision 50810)
+++ trunk/phase3/languages/messages/MessagesEn.php	(revision 50811)
@@ -210,7 +210,8 @@
 	'toc'                    => array( 0,    '__TOC__'                ),
 	'noeditsection'          => array( 0,    '__NOEDITSECTION__'      ),
 	'noheader'               => array( 0,    '__NOHEADER__'           ),
-	'currentmonth'           => array( 1,    'CURRENTMONTH'           ),
+	'currentmonth'           => array( 1,    'CURRENTMONTH', 'CURRENTMONTH2' ),
+	'currentmonth1'          => array( 1,    'CURRENTMONTH1'          ),
 	'currentmonthname'       => array( 1,    'CURRENTMONTHNAME'       ),
 	'currentmonthnamegen'    => array( 1,    'CURRENTMONTHNAMEGEN'    ),
 	'currentmonthabbrev'     => array( 1,    'CURRENTMONTHABBREV'     ),
@@ -220,7 +221,8 @@
 	'currentyear'            => array( 1,    'CURRENTYEAR'            ),
 	'currenttime'            => array( 1,    'CURRENTTIME'            ),
 	'currenthour'            => array( 1,    'CURRENTHOUR'            ),
-	'localmonth'             => array( 1,    'LOCALMONTH'             ),
+	'localmonth'             => array( 1,    'LOCALMONTH', 'LOCALMONTH2' ),
+	'localmonth1'            => array( 1,    'LOCALMONTH1'             ),
 	'localmonthname'         => array( 1,    'LOCALMONTHNAME'         ),
 	'localmonthnamegen'      => array( 1,    'LOCALMONTHNAMEGEN'      ),
 	'localmonthabbrev'       => array( 1,    'LOCALMONTHABBREV'       ),
Index: trunk/phase3/RELEASE-NOTES
===================================================================
--- trunk/phase3/RELEASE-NOTES	(revision 50810)
+++ trunk/phase3/RELEASE-NOTES	(revision 50811)
@@ -63,6 +63,8 @@
 * Database: unionQueries function to be used for UNION sql construction, so 
   it can be overloaded on DB abstraction level for DB specific functionality
 * (bug 18849) Implement Japanese and North Korean calendars
+* (bug 5755) Introduce {{CURRENTMONTH1}} and {{LOCALMONTH1}} to display the
+  month number without the leading zero
 
 === Bug fixes in 1.16 ===
 

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

Views
Toolbox