r23017 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23016‎ | r23017 | r23018 >
Date:19:07, 15 June 2007
Author:brion
Status:old
Tags:
Comment:
* (bug 8577) Fix some weird misapplications of time zones.
{{CURRENT*}} functions now consistently use UTC as intended, while
{{LOCAL*}} functions return local time per server config or $wgLocaltimezone.
Signature dates for Japanese and other languages including weekday now show
the correct day to match the rest of the time in local time.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/Parser.php (modified) (history)
  • /trunk/phase3/languages/Language.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Parser.php
@@ -2431,17 +2431,17 @@
24322432
24332433 switch ( $index ) {
24342434 case 'currentmonth':
2435 - return $varCache[$index] = $wgContLang->formatNum( date( 'm', $ts ) );
 2435+ return $varCache[$index] = $wgContLang->formatNum( gmdate( 'm', $ts ) );
24362436 case 'currentmonthname':
2437 - return $varCache[$index] = $wgContLang->getMonthName( date( 'n', $ts ) );
 2437+ return $varCache[$index] = $wgContLang->getMonthName( gmdate( 'n', $ts ) );
24382438 case 'currentmonthnamegen':
2439 - return $varCache[$index] = $wgContLang->getMonthNameGen( date( 'n', $ts ) );
 2439+ return $varCache[$index] = $wgContLang->getMonthNameGen( gmdate( 'n', $ts ) );
24402440 case 'currentmonthabbrev':
2441 - return $varCache[$index] = $wgContLang->getMonthAbbreviation( date( 'n', $ts ) );
 2441+ return $varCache[$index] = $wgContLang->getMonthAbbreviation( gmdate( 'n', $ts ) );
24422442 case 'currentday':
2443 - return $varCache[$index] = $wgContLang->formatNum( date( 'j', $ts ) );
 2443+ return $varCache[$index] = $wgContLang->formatNum( gmdate( 'j', $ts ) );
24442444 case 'currentday2':
2445 - return $varCache[$index] = $wgContLang->formatNum( date( 'd', $ts ) );
 2445+ return $varCache[$index] = $wgContLang->formatNum( gmdate( 'd', $ts ) );
24462446 case 'localmonth':
24472447 return $varCache[$index] = $wgContLang->formatNum( $localMonth );
24482448 case 'localmonthname':
@@ -2515,19 +2515,19 @@
25162516 case 'subjectspacee':
25172517 return( wfUrlencode( $this->mTitle->getSubjectNsText() ) );
25182518 case 'currentdayname':
2519 - return $varCache[$index] = $wgContLang->getWeekdayName( date( 'w', $ts ) + 1 );
 2519+ return $varCache[$index] = $wgContLang->getWeekdayName( gmdate( 'w', $ts ) + 1 );
25202520 case 'currentyear':
2521 - return $varCache[$index] = $wgContLang->formatNum( date( 'Y', $ts ), true );
 2521+ return $varCache[$index] = $wgContLang->formatNum( gmdate( 'Y', $ts ), true );
25222522 case 'currenttime':
25232523 return $varCache[$index] = $wgContLang->time( wfTimestamp( TS_MW, $ts ), false, false );
25242524 case 'currenthour':
2525 - return $varCache[$index] = $wgContLang->formatNum( date( 'H', $ts ), true );
 2525+ return $varCache[$index] = $wgContLang->formatNum( gmdate( 'H', $ts ), true );
25262526 case 'currentweek':
25272527 // @bug 4594 PHP5 has it zero padded, PHP4 does not, cast to
25282528 // int to remove the padding
2529 - return $varCache[$index] = $wgContLang->formatNum( (int)date( 'W', $ts ) );
 2529+ return $varCache[$index] = $wgContLang->formatNum( (int)gmdate( 'W', $ts ) );
25302530 case 'currentdow':
2531 - return $varCache[$index] = $wgContLang->formatNum( date( 'w', $ts ) );
 2531+ return $varCache[$index] = $wgContLang->formatNum( gmdate( 'w', $ts ) );
25322532 case 'localdayname':
25332533 return $varCache[$index] = $wgContLang->getWeekdayName( $localDayOfWeek + 1 );
25342534 case 'localyear':
Index: trunk/phase3/languages/Language.php
@@ -472,6 +472,9 @@
473473 * i's" => 20'11"
474474 *
475475 * Backslash escaping is also supported.
 476+ *
 477+ * Input timestamp is assumed to be pre-normalized to the desired local
 478+ * time zone, if any.
476479 *
477480 * @param string $format
478481 * @param string $ts 14-character timestamp
@@ -512,31 +515,31 @@
513516 break;
514517 case 'D':
515518 if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
516 - $s .= $this->getWeekdayAbbreviation( date( 'w', $unix ) + 1 );
 519+ $s .= $this->getWeekdayAbbreviation( gmdate( 'w', $unix ) + 1 );
517520 break;
518521 case 'j':
519522 $num = intval( substr( $ts, 6, 2 ) );
520523 break;
521524 case 'l':
522525 if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
523 - $s .= $this->getWeekdayName( date( 'w', $unix ) + 1 );
 526+ $s .= $this->getWeekdayName( gmdate( 'w', $unix ) + 1 );
524527 break;
525528 case 'N':
526529 if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
527 - $w = date( 'w', $unix );
 530+ $w = gmdate( 'w', $unix );
528531 $num = $w ? $w : 7;
529532 break;
530533 case 'w':
531534 if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
532 - $num = date( 'w', $unix );
 535+ $num = gmdate( 'w', $unix );
533536 break;
534537 case 'z':
535538 if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
536 - $num = date( 'z', $unix );
 539+ $num = gmdate( 'z', $unix );
537540 break;
538541 case 'W':
539542 if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
540 - $num = date( 'W', $unix );
 543+ $num = gmdate( 'W', $unix );
541544 break;
542545 case 'F':
543546 $s .= $this->getMonthName( substr( $ts, 4, 2 ) );
@@ -552,11 +555,11 @@
553556 break;
554557 case 't':
555558 if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
556 - $num = date( 't', $unix );
 559+ $num = gmdate( 't', $unix );
557560 break;
558561 case 'L':
559562 if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
560 - $num = date( 'L', $unix );
 563+ $num = gmdate( 'L', $unix );
561564 break;
562565 case 'Y':
563566 $num = substr( $ts, 0, 4 );
@@ -592,11 +595,11 @@
593596 break;
594597 case 'c':
595598 if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
596 - $s .= date( 'c', $unix );
 599+ $s .= gmdate( 'c', $unix );
597600 break;
598601 case 'r':
599602 if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
600 - $s .= date( 'r', $unix );
 603+ $s .= gmdate( 'r', $unix );
601604 break;
602605 case 'U':
603606 if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
Index: trunk/phase3/RELEASE-NOTES
@@ -166,6 +166,11 @@
167167 * (bug 10247) Fix IP address regex to avoid false positive IPv6 matches
168168 * (bug 9948) Workaround for diff regression with old Mozilla versions
169169 * (bug 10265) Fix regression in category image gallery paging
 170+* (bug 8577) Fix some weird misapplications of time zones.
 171+ {{CURRENT*}} functions now consistently use UTC as intended, while
 172+ {{LOCAL*}} functions return local time per server config or $wgLocaltimezone.
 173+ Signature dates for Japanese and other languages including weekday now show
 174+ the correct day to match the rest of the time in local time.
170175
171176
172177 == API changes since 1.10 ==

Follow-up revisions

RevisionCommit summaryAuthorDate
r23039Merged revisions 22967-23037 via svnmerge from...david20:15, 16 June 2007

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r19633* miscellaneous German updates by raymond...leon17:05, 24 January 2007

Status & tagging log