<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[12508] branches/2.9: Do not use deprecated Etc timezones.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/12508">12508</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2009-12-23 14:17:55 +0000 (Wed, 23 Dec 2009)</dd>
</dl>
<h3>Log Message</h3>
<pre>Do not use deprecated Etc timezones. Props miqrogroove. fixes <a href="http://trac.wordpress.org/ticket/11558">#11558</a> for 2.9</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branches29wpadminoptionsgeneralphp">branches/2.9/wp-admin/options-general.php</a></li>
<li><a href="#branches29wpadminoptionsphp">branches/2.9/wp-admin/options.php</a></li>
<li><a href="#branches29wpincludesfunctionsphp">branches/2.9/wp-includes/functions.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="branches29wpadminoptionsgeneralphp"></a>
<div class="modfile"><h4>Modified: branches/2.9/wp-admin/options-general.php (12507 => 12508)</h4>
<pre class="diff"><span>
<span class="info">--- branches/2.9/wp-admin/options-general.php        2009-12-23 14:16:36 UTC (rev 12507)
+++ branches/2.9/wp-admin/options-general.php        2009-12-23 14:17:55 UTC (rev 12508)
</span><span class="lines">@@ -139,11 +139,23 @@
</span><span class="cx"> else: // looks like we can do nice timezone selection!
</span><span class="cx"> $current_offset = get_option('gmt_offset');
</span><span class="cx"> $tzstring = get_option('timezone_string');
</span><ins>+
+$check_zone_info = true;
+
+// Remove old Etc mappings. Fallback to gmt_offset.
+if ( false !== strpos($tzstring,'Etc/GMT') )
+        $tzstring = '';
+
</ins><span class="cx"> if (empty($tzstring)) { // set the Etc zone if no timezone string exists
</span><del>-        if ($current_offset < 0) $offnum = - ceil($current_offset);
-        else $offnum = - floor($current_offset);
-        $tzstring = 'Etc/GMT' . (($offnum >= 0) ? '+' : '') . $offnum;
</del><ins>+        $check_zone_info = false;
+        if ( 0 == $current_offset )
+                $tzstring = 'UTC+0';
+        elseif ($current_offset < 0)
+                $tzstring = 'UTC' . $current_offset;
+        else
+                $tzstring = 'UTC+' . $current_offset;
</ins><span class="cx"> }
</span><ins>+
</ins><span class="cx"> ?>
</span><span class="cx"> <th scope="row"><label for="timezone_string"><?php _e('Timezone') ?></label></th>
</span><span class="cx"> <td>
</span><span class="lines">@@ -160,7 +172,7 @@
</span><span class="cx"> <span class="description"><?php _e('Choose a city in the same timezone as you.'); ?></span>
</span><span class="cx"> <br />
</span><span class="cx"> <span>
</span><del>-<?php if ($tzstring) : ?>
</del><ins>+<?php if ($check_zone_info && $tzstring) : ?>
</ins><span class="cx">         <?php
</span><span class="cx">         $now = localtime(time(),true);
</span><span class="cx">         if ($now['tm_isdst']) _e('This timezone is currently in daylight savings time.');
</span></span></pre></div>
<a id="branches29wpadminoptionsphp"></a>
<div class="modfile"><h4>Modified: branches/2.9/wp-admin/options.php (12507 => 12508)</h4>
<pre class="diff"><span>
<span class="info">--- branches/2.9/wp-admin/options.php        2009-12-23 14:16:36 UTC (rev 12507)
+++ branches/2.9/wp-admin/options.php        2009-12-23 14:17:55 UTC (rev 12508)
</span><span class="lines">@@ -65,6 +65,12 @@
</span><span class="cx">                         $_POST['date_format'] = $_POST['date_format_custom'];
</span><span class="cx">                 if ( !empty($_POST['time_format']) && isset($_POST['time_format_custom']) && '\c\u\s\t\o\m' == stripslashes( $_POST['time_format'] ) )
</span><span class="cx">                         $_POST['time_format'] = $_POST['time_format_custom'];
</span><ins>+                // Map UTC+- timezones to gmt_offsets and set timezone_string to empty.
+                if ( !empty($_POST['timezone_string']) && preg_match('/^UTC[+-]/', $_POST['timezone_string']) ) {
+                        $_POST['gmt_offset'] = $_POST['timezone_string'];
+                        $_POST['gmt_offset'] = preg_replace('/UTC\+?/', '', $_POST['gmt_offset']);
+                        $_POST['timezone_string'] = '';
+                }
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if ( $options ) {
</span></span></pre></div>
<a id="branches29wpincludesfunctionsphp"></a>
<div class="modfile"><h4>Modified: branches/2.9/wp-includes/functions.php (12507 => 12508)</h4>
<pre class="diff"><span>
<span class="info">--- branches/2.9/wp-includes/functions.php        2009-12-23 14:16:36 UTC (rev 12507)
+++ branches/2.9/wp-includes/functions.php        2009-12-23 14:17:55 UTC (rev 12508)
</span><span class="lines">@@ -3393,7 +3393,7 @@
</span><span class="cx"> function wp_timezone_choice( $selected_zone ) {
</span><span class="cx">         static $mo_loaded = false;
</span><span class="cx">
</span><del>-        $continents = array( 'Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Atlantic', 'Australia', 'Europe', 'Indian', 'Pacific', 'Etc' );
</del><ins>+        $continents = array( 'Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Atlantic', 'Australia', 'Europe', 'Indian', 'Pacific');
</ins><span class="cx">
</span><span class="cx">         // Load translations for continents and cities
</span><span class="cx">         if ( !$mo_loaded ) {
</span><span class="lines">@@ -3409,9 +3409,6 @@
</span><span class="cx">                 if ( !in_array( $zone[0], $continents ) ) {
</span><span class="cx">                         continue;
</span><span class="cx">                 }
</span><del>-                if ( 'Etc' === $zone[0] && in_array( $zone[1], array( 'UCT', 'GMT', 'GMT0', 'GMT+0', 'GMT-0', 'Greenwich', 'Universal', 'Zulu' ) ) ) {
-                        continue;
-                }
</del><span class="cx">
</span><span class="cx">                 // This determines what gets set and translated - we don't translate Etc/* strings here, they are done later
</span><span class="cx">                 $exists = array(
</span><span class="lines">@@ -3452,27 +3449,18 @@
</span><span class="cx">
</span><span class="cx">                         // Continent optgroup
</span><span class="cx">                         if ( !isset( $zonen[$key - 1] ) || $zonen[$key - 1]['continent'] !== $zone['continent'] ) {
</span><del>-                                $label = ( 'Etc' === $zone['continent'] ) ? __( 'Manual offsets' ) : $zone['t_continent'];
</del><ins>+                                $label = $zone['t_continent'];
</ins><span class="cx">                                 $structure[] = '<optgroup label="'. esc_attr( $label ) .'">';
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         // Add the city to the value
</span><span class="cx">                         $value[] = $zone['city'];
</span><del>-                        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'];
-                                }
</del><ins>+
+                        $display = $zone['t_city'];
+                        if ( !empty( $zone['subcity'] ) ) {
+                                // Add the subcity to the value
+                                $value[] = $zone['subcity'];
+                                $display .= ' - ' . $zone['t_subcity'];
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="lines">@@ -3490,6 +3478,36 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><ins>+        // Do UTC
+        $structure[] = '<optgroup label="'. esc_attr__( 'UTC' ) .'">';
+        $selected = '';
+        if ( 'UTC' === $selected_zone )
+                $selected = 'selected="selected" ';
+        $structure[] = '<option ' . $selected . 'value="' . esc_attr( 'UTC' ) . '">' . __('UTC') . '</option>';
+        $structure[] = '</optgroup>';
+
+        // Do manual UTC offsets
+        $structure[] = '<optgroup label="'. esc_attr__( 'Manual Offsets' ) .'">';
+        $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[] = '<option ' . $selected . 'value="' . esc_attr( $offset_value ) . '">' . esc_html( $offset_name ) . "</option>";
+                
+        }
+        $structure[] = '</optgroup>';
+
</ins><span class="cx">         return join( "\n", $structure );
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>