r6884 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r6883‎ | r6884 | r6885 >
Date:03:27, 29 December 2004
Author:vibber
Status:old
Tags:
Comment:
* (bug 1224) Use proper date messages for date reformatter
Modified paths:
  • /trunk/phase3/includes/DateFormatter.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/DateFormatter.php
@@ -47,14 +47,14 @@
4848 * @todo document
4949 */
5050 function DateFormatter() {
51 - global $wgMonthNamesEn, $wgMonthAbbreviationsEn, $wgInputEncoding;
 51+ global $wgContLang, $wgInputEncoding;
5252
5353 $this->monthNames = $this->getMonthRegex();
5454 for ( $i=1; $i<=12; $i++ ) {
55 - $this->xMonths[strtolower( $wgMonthNamesEn[$i-1] )] = $i;
 55+ $this->xMonths[strtolower( $wgContLang->getMonthName( $i ) )] = $i;
5656 }
5757 for ( $i=1; $i<=12; $i++ ) {
58 - $this->xMonths[strtolower( $wgMonthAbbreviationsEn[$i-1] )] = $i;
 58+ $this->xMonths[strtolower( $wgContLang->getMonthAbbreviation( $i ) )] = $i;
5959 }
6060
6161 # Attempt at UTF-8 support, untested at the moment
@@ -140,7 +140,6 @@
141141 * @param $matches
142142 */
143143 function replace( $matches ) {
144 - global $wgMonthNamesEn;
145144 # Extract information from $matches
146145 $bits = array();
147146 $key = $this->keys[$this->mSource];
@@ -160,14 +159,14 @@
161160 $char = $format{$p};
162161 switch ( $char ) {
163162 case 'd': # ISO day of month
164 - if ( is_null($bits['d']) ) {
 163+ if ( !isset($bits['d']) ) {
165164 $text .= sprintf( '%02d', $bits['j'] );
166165 } else {
167166 $text .= $bits['d'];
168167 }
169168 break;
170169 case 'm': # ISO month
171 - if ( is_null($bits['m']) ) {
 170+ if ( !isset($bits['m']) ) {
172171 $m = $this->makeIsoMonth( $bits['F'] );
173172 if ( !$m || $m == '00' ) {
174173 $fail = true;
@@ -179,33 +178,34 @@
180179 }
181180 break;
182181 case 'y': # ISO year
183 - if ( is_null( $bits['y'] ) ) {
 182+ if ( !isset( $bits['y'] ) ) {
184183 $text .= $this->makeIsoYear( $bits['Y'] );
185184 } else {
186185 $text .= $bits['y'];
187186 }
188187 break;
189188 case 'j': # ordinary day of month
190 - if ( is_null($bits['j']) ) {
 189+ if ( !isset($bits['j']) ) {
191190 $text .= IntVal( $bits['d'] );
192191 } else {
193192 $text .= $bits['j'];
194193 }
195194 break;
196195 case 'F': # long month
197 - if ( is_null( $bits['F'] ) ) {
 196+ if ( !isset( $bits['F'] ) ) {
198197 $m = IntVal($bits['m']);
199198 if ( $m > 12 || $m < 1 ) {
200199 $fail = true;
201200 } else {
202 - $text .= $wgMonthNamesEn[$m-1];
 201+ global $wgContLang;
 202+ $text .= $wgContLang->getMonthName( $m );
203203 }
204204 } else {
205205 $text .= ucfirst( $bits['F'] );
206206 }
207207 break;
208208 case 'Y': # ordinary (optional BC) year
209 - if ( is_null( $bits['Y'] ) ) {
 209+ if ( !isset( $bits['Y'] ) ) {
210210 $text .= $this->makeNormalYear( $bits['y'] );
211211 } else {
212212 $text .= $bits['Y'];
@@ -225,8 +225,13 @@
226226 * @todo document
227227 */
228228 function getMonthRegex() {
229 - global $wgMonthNamesEn, $wgMonthAbbreviationsEn;
230 - return implode( '|', array_merge($wgMonthNamesEn, $wgMonthAbbreviationsEn));
 229+ global $wgContLang;
 230+ $names = array();
 231+ for( $i = 1; $i <= 12; $i++ ) {
 232+ $names[] = $wgContLang->getMonthName( $i );
 233+ $names[] = $wgContLang->getMonthAbbreviation( $i );
 234+ }
 235+ return implode( '|', $names );
231236 }
232237
233238 /**

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r6883* (bug 1224) Use proper date messages for date reformattervibber03:23, 29 December 2004

Status & tagging log