From 3a07a052c9d34ad30c14783c2ca6832da7cfb4ed Mon Sep 17 00:00:00 2001 From: Alexandre Emsenhuber Date: Sat, 15 Oct 2011 09:11:29 +0000 Subject: [PATCH] * Timezones are now recognised in user preferences when offset is different due to DST --- RELEASE-NOTES-1.19 | 2 ++ includes/Preferences.php | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/RELEASE-NOTES-1.19 b/RELEASE-NOTES-1.19 index a7244714ae..a07c7b30ff 100644 --- a/RELEASE-NOTES-1.19 +++ b/RELEASE-NOTES-1.19 @@ -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. diff --git a/includes/Preferences.php b/includes/Preferences.php index 186aa0c619..b060230961 100644 --- a/includes/Preferences.php +++ b/includes/Preferences.php @@ -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', -- 2.20.1