* (bug 8577) Fix some weird misapplications of time zones.
authorBrion Vibber <brion@users.mediawiki.org>
Fri, 15 Jun 2007 19:07:15 +0000 (19:07 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Fri, 15 Jun 2007 19:07:15 +0000 (19:07 +0000)
  {{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.

RELEASE-NOTES
includes/Parser.php
languages/Language.php

index 0ef63df..7e0f505 100644 (file)
@@ -166,6 +166,11 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 10247) Fix IP address regex to avoid false positive IPv6 matches
 * (bug 9948) Workaround for diff regression with old Mozilla versions
 * (bug 10265) Fix regression in category image gallery paging
+* (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.
 
 
 == API changes since 1.10 ==
index 2d67bf2..eb6739f 100644 (file)
@@ -2431,17 +2431,17 @@ class Parser
 
                switch ( $index ) {
                        case 'currentmonth':
-                               return $varCache[$index] = $wgContLang->formatNum( date( 'm', $ts ) );
+                               return $varCache[$index] = $wgContLang->formatNum( gmdate( 'm', $ts ) );
                        case 'currentmonthname':
-                               return $varCache[$index] = $wgContLang->getMonthName( date( 'n', $ts ) );
+                               return $varCache[$index] = $wgContLang->getMonthName( gmdate( 'n', $ts ) );
                        case 'currentmonthnamegen':
-                               return $varCache[$index] = $wgContLang->getMonthNameGen( date( 'n', $ts ) );
+                               return $varCache[$index] = $wgContLang->getMonthNameGen( gmdate( 'n', $ts ) );
                        case 'currentmonthabbrev':
-                               return $varCache[$index] = $wgContLang->getMonthAbbreviation( date( 'n', $ts ) );
+                               return $varCache[$index] = $wgContLang->getMonthAbbreviation( gmdate( 'n', $ts ) );
                        case 'currentday':
-                               return $varCache[$index] = $wgContLang->formatNum( date( 'j', $ts ) );
+                               return $varCache[$index] = $wgContLang->formatNum( gmdate( 'j', $ts ) );
                        case 'currentday2':
-                               return $varCache[$index] = $wgContLang->formatNum( date( 'd', $ts ) );
+                               return $varCache[$index] = $wgContLang->formatNum( gmdate( 'd', $ts ) );
                        case 'localmonth':
                                return $varCache[$index] = $wgContLang->formatNum( $localMonth );
                        case 'localmonthname':
@@ -2515,19 +2515,19 @@ class Parser
                        case 'subjectspacee':
                                return( wfUrlencode( $this->mTitle->getSubjectNsText() ) );
                        case 'currentdayname':
-                               return $varCache[$index] = $wgContLang->getWeekdayName( date( 'w', $ts ) + 1 );
+                               return $varCache[$index] = $wgContLang->getWeekdayName( gmdate( 'w', $ts ) + 1 );
                        case 'currentyear':
-                               return $varCache[$index] = $wgContLang->formatNum( date( 'Y', $ts ), true );
+                               return $varCache[$index] = $wgContLang->formatNum( gmdate( 'Y', $ts ), true );
                        case 'currenttime':
                                return $varCache[$index] = $wgContLang->time( wfTimestamp( TS_MW, $ts ), false, false );
                        case 'currenthour':
-                               return $varCache[$index] = $wgContLang->formatNum( date( 'H', $ts ), true );
+                               return $varCache[$index] = $wgContLang->formatNum( gmdate( 'H', $ts ), true );
                        case 'currentweek':
                                // @bug 4594 PHP5 has it zero padded, PHP4 does not, cast to
                                // int to remove the padding
-                               return $varCache[$index] = $wgContLang->formatNum( (int)date( 'W', $ts ) );
+                               return $varCache[$index] = $wgContLang->formatNum( (int)gmdate( 'W', $ts ) );
                        case 'currentdow':
-                               return $varCache[$index] = $wgContLang->formatNum( date( 'w', $ts ) );
+                               return $varCache[$index] = $wgContLang->formatNum( gmdate( 'w', $ts ) );
                        case 'localdayname':
                                return $varCache[$index] = $wgContLang->getWeekdayName( $localDayOfWeek + 1 );
                        case 'localyear':
index d36b549..8cba189 100644 (file)
@@ -472,6 +472,9 @@ class Language {
         * i's"                   => 20'11"
         *
         * Backslash escaping is also supported.
+        *
+        * Input timestamp is assumed to be pre-normalized to the desired local
+        * time zone, if any.
         * 
         * @param string $format
         * @param string $ts 14-character timestamp
@@ -512,31 +515,31 @@ class Language {
                                        break;
                                case 'D':
                                        if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
-                                       $s .= $this->getWeekdayAbbreviation( date( 'w', $unix ) + 1 );
+                                       $s .= $this->getWeekdayAbbreviation( gmdate( 'w', $unix ) + 1 );
                                        break;
                                case 'j':
                                        $num = intval( substr( $ts, 6, 2 ) );
                                        break;
                                case 'l':
                                        if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
-                                       $s .= $this->getWeekdayName( date( 'w', $unix ) + 1 );
+                                       $s .= $this->getWeekdayName( gmdate( 'w', $unix ) + 1 );
                                        break;
                                case 'N':
                                        if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
-                                       $w = date( 'w', $unix );
+                                       $w = gmdate( 'w', $unix );
                                        $num = $w ? $w : 7;
                                        break;
                                case 'w':
                                        if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
-                                       $num = date( 'w', $unix );
+                                       $num = gmdate( 'w', $unix );
                                        break;
                                case 'z':
                                        if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
-                                       $num = date( 'z', $unix );
+                                       $num = gmdate( 'z', $unix );
                                        break;
                                case 'W':
                                        if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
-                                       $num = date( 'W', $unix );
+                                       $num = gmdate( 'W', $unix );
                                        break;                                  
                                case 'F':
                                        $s .= $this->getMonthName( substr( $ts, 4, 2 ) );
@@ -552,11 +555,11 @@ class Language {
                                        break;
                                case 't':
                                        if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
-                                       $num = date( 't', $unix );
+                                       $num = gmdate( 't', $unix );
                                        break;
                                case 'L':
                                        if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
-                                       $num = date( 'L', $unix );
+                                       $num = gmdate( 'L', $unix );
                                        break;                                  
                                case 'Y':
                                        $num = substr( $ts, 0, 4 );
@@ -592,11 +595,11 @@ class Language {
                                        break;
                                case 'c':
                                        if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
-                                       $s .= date( 'c', $unix );
+                                       $s .= gmdate( 'c', $unix );
                                        break;
                                case 'r':
                                        if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );
-                                       $s .= date( 'r', $unix );
+                                       $s .= gmdate( 'r', $unix );
                                        break;
                                case 'U':
                                        if ( !$unix ) $unix = wfTimestamp( TS_UNIX, $ts );