* Timezones are now recognised in user preferences when offset is different due to DST
authorAlexandre Emsenhuber <ialex@users.mediawiki.org>
Sat, 15 Oct 2011 09:11:29 +0000 (09:11 +0000)
committerAlexandre Emsenhuber <ialex@users.mediawiki.org>
Sat, 15 Oct 2011 09:11:29 +0000 (09:11 +0000)
RELEASE-NOTES-1.19
includes/Preferences.php

index a724471..a07c7b3 100644 (file)
@@ -107,6 +107,8 @@ production.
 * (bug 31081) $wgEnotifUseJobQ causes many unnecessary jobs to be queued
 * (bug 30202) File names are now restricted on upload to 240 bytes, because of
   restrictions on some of the database fields.
+* Timezones are now recognised in user preferences when offset is different
+  due to DST
 
 === API changes in 1.19 ===
 * (bug 19838) siprop=interwikimap can now use the interwiki cache.
index 186aa0c..b060230 100644 (file)
@@ -569,18 +569,29 @@ class Preferences {
 
                // Grab existing pref.
                $tzOffset = $user->getOption( 'timecorrection' );
-               $tz = explode( '|', $tzOffset, 2 );
+               $tz = explode( '|', $tzOffset, 3 );
+
+               $tzOptions = self::getTimezoneOptions( $context );
 
                $tzSetting = $tzOffset;
                if ( count( $tz ) > 1 && $tz[0] == 'Offset' ) {
                        $minDiff = $tz[1];
                        $tzSetting = sprintf( '%+03d:%02d', floor( $minDiff / 60 ), abs( $minDiff ) % 60 );
+               } elseif ( count( $tz ) > 1 && $tz[0] == 'ZoneInfo' &&
+                       !in_array( $tzOffset, HTMLFormField::flattenOptions( $tzOptions ) ) )
+               {
+                       # Timezone offset can vary with DST
+                       $userTZ = timezone_open( $tz[2] );
+                       if ( $userTZ !== false ) {
+                               $minDiff = floor( timezone_offset_get( $userTZ, date_create( 'now' ) ) / 60 );
+                               $tzSetting = "ZoneInfo|$minDiff|{$tz[2]}";
+                       }
                }
 
                $defaultPreferences['timecorrection'] = array(
                        'class' => 'HTMLSelectOrOtherField',
                        'label-message' => 'timezonelegend',
-                       'options' => self::getTimezoneOptions( $context ),
+                       'options' => $tzOptions,
                        'default' => $tzSetting,
                        'size' => 20,
                        'section' => 'datetime/timeoffset',