From 95835a693a6102cb2c17db6c2045dbe63f5b368d Mon Sep 17 00:00:00 2001 From: ryan Date: Wed, 23 Dec 2009 14:16:36 +0000 Subject: [PATCH] Do not use deprecated Etc timezones. Props miqrogroove. fixes #11558 for trunk git-svn-id: http://svn.automattic.com/wordpress/trunk@12507 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/options-general.php | 22 ++++++++++---- wp-admin/options.php | 6 ++++ wp-includes/functions.php | 58 +++++++++++++++++++++++------------- 3 files changed, 61 insertions(+), 25 deletions(-) diff --git a/wp-admin/options-general.php b/wp-admin/options-general.php index def2124985..c6e4734770 100644 --- a/wp-admin/options-general.php +++ b/wp-admin/options-general.php @@ -139,11 +139,23 @@ foreach ( $offset_range as $offset ) { else: // looks like we can do nice timezone selection! $current_offset = get_option('gmt_offset'); $tzstring = get_option('timezone_string'); -if (empty($tzstring)) { // set the Etc zone if no timezone string exists - if ($current_offset < 0) $offnum = - ceil($current_offset); - else $offnum = - floor($current_offset); - $tzstring = 'Etc/GMT' . (($offnum >= 0) ? '+' : '') . $offnum; + +$check_zone_info = true; + +// Remove old Etc mappings. Fallback to gmt_offset. +if ( false !== strpos($tzstring,'Etc/GMT') ) + $tzstring = ''; + +if (empty($tzstring)) { // Create a UTC+- zone if no timezone string exists + $check_zone_info = false; + if ( 0 == $current_offset ) + $tzstring = 'UTC+0'; + elseif ($current_offset < 0) + $tzstring = 'UTC' . $current_offset; + else + $tzstring = 'UTC+' . $current_offset; } + ?> @@ -160,7 +172,7 @@ if (empty($tzstring)) { // set the Etc zone if no timezone string exists
- + '; } // Add the city to the value $value[] = $zone['city']; - if ( 'Etc' === $zone['continent'] ) { - if ( 'UTC' === $zone['city'] ) { - $display = ''; - } else { - $display = str_replace( 'GMT', '', $zone['city'] ); - $display = strtr( $display, '+-', '-+' ) . ':00'; - } - $display = sprintf( __( 'UTC %s' ), $display ); - } else { - $display = $zone['t_city']; - if ( !empty( $zone['subcity'] ) ) { - // Add the subcity to the value - $value[] = $zone['subcity']; - $display .= ' - ' . $zone['t_subcity']; - } + + $display = $zone['t_city']; + if ( !empty( $zone['subcity'] ) ) { + // Add the subcity to the value + $value[] = $zone['subcity']; + $display .= ' - ' . $zone['t_subcity']; } } @@ -3490,6 +3478,36 @@ function wp_timezone_choice( $selected_zone ) { } } + // Do UTC + $structure[] = ''; + $selected = ''; + if ( 'UTC' === $selected_zone ) + $selected = 'selected="selected" '; + $structure[] = ''; + $structure[] = ''; + + // Do manual UTC offsets + $structure[] = ''; + $offset_range = array (-12, -11.5, -11, -10.5, -10, -9.5, -9, -8.5, -8, -7.5, -7, -6.5, -6, -5.5, -5, -4.5, -4, -3.5, -3, -2.5, -2, -1.5, -1, -0.5, + 0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 5.75, 6, 6.5, 7, 7.5, 8, 8.5, 8.75, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.75, 13, 13.75, 14); + foreach ( $offset_range as $offset ) { + if ( 0 <= $offset ) + $offset_name = '+' . $offset; + else + $offset_name = (string) $offset; + + $offset_value = $offset_name; + $offset_name = str_replace(array('.25','.5','.75'), array(':15',':30',':45'), $offset_name); + $offset_name = 'UTC' . $offset_name; + $offset_value = 'UTC' . $offset_value; + $selected = ''; + if ( $offset_value === $selected_zone ) + $selected = 'selected="selected" '; + $structure[] = '"; + + } + $structure[] = ''; + return join( "\n", $structure ); }