<!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>[12507] trunk: Do not use deprecated Etc timezones.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/12507">12507</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2009-12-23 14:16:36 +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 trunk</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminoptionsgeneralphp">trunk/wp-admin/options-general.php</a></li>
<li><a href="#trunkwpadminoptionsphp">trunk/wp-admin/options.php</a></li>
<li><a href="#trunkwpincludesfunctionsphp">trunk/wp-includes/functions.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminoptionsgeneralphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/options-general.php (12506 => 12507)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/options-general.php        2009-12-23 13:03:34 UTC (rev 12506)
+++ trunk/wp-admin/options-general.php        2009-12-23 14:16:36 UTC (rev 12507)
</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><del>-if (empty($tzstring)) { // set the Etc zone if no timezone string exists
-        if ($current_offset &lt; 0) $offnum = - ceil($current_offset);
-        else $offnum = - floor($current_offset);
-        $tzstring = 'Etc/GMT' . (($offnum &gt;= 0) ? '+' : '') . $offnum;
</del><ins>+
+$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 &lt; 0)
+                $tzstring = 'UTC' . $current_offset;
+        else
+                $tzstring = 'UTC+' . $current_offset;
</ins><span class="cx"> }
</span><ins>+
</ins><span class="cx"> ?&gt;
</span><span class="cx"> &lt;th scope=&quot;row&quot;&gt;&lt;label for=&quot;timezone_string&quot;&gt;&lt;?php _e('Timezone') ?&gt;&lt;/label&gt;&lt;/th&gt;
</span><span class="cx"> &lt;td&gt;
</span><span class="lines">@@ -160,7 +172,7 @@
</span><span class="cx"> &lt;span class=&quot;description&quot;&gt;&lt;?php _e('Choose a city in the same timezone as you.'); ?&gt;&lt;/span&gt;
</span><span class="cx"> &lt;br /&gt;
</span><span class="cx"> &lt;span&gt;
</span><del>-&lt;?php if ($tzstring) : ?&gt;
</del><ins>+&lt;?php if ($check_zone_info &amp;&amp; $tzstring) : ?&gt;
</ins><span class="cx">         &lt;?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="trunkwpadminoptionsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/options.php (12506 => 12507)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/options.php        2009-12-23 13:03:34 UTC (rev 12506)
+++ trunk/wp-admin/options.php        2009-12-23 14:16:36 UTC (rev 12507)
</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']) &amp;&amp; isset($_POST['time_format_custom']) &amp;&amp; '\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']) &amp;&amp; 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="trunkwpincludesfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/functions.php (12506 => 12507)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/functions.php        2009-12-23 13:03:34 UTC (rev 12506)
+++ trunk/wp-includes/functions.php        2009-12-23 14:16:36 UTC (rev 12507)
</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] &amp;&amp; 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[] = '&lt;optgroup label=&quot;'. esc_attr( $label ) .'&quot;&gt;';
</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[] = '&lt;optgroup label=&quot;'. esc_attr__( 'UTC' ) .'&quot;&gt;';
+        $selected = '';
+        if ( 'UTC' === $selected_zone )
+                $selected = 'selected=&quot;selected&quot; ';
+        $structure[] = '&lt;option ' . $selected . 'value=&quot;' . esc_attr( 'UTC' ) . '&quot;&gt;' . __('UTC') . '&lt;/option&gt;';
+        $structure[] = '&lt;/optgroup&gt;';
+
+        // Do manual UTC offsets
+        $structure[] = '&lt;optgroup label=&quot;'. esc_attr__( 'Manual Offsets' ) .'&quot;&gt;';
+        $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 &lt;= $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=&quot;selected&quot; ';
+                $structure[] = '&lt;option ' . $selected . 'value=&quot;' . esc_attr( $offset_value ) . '&quot;&gt;' . esc_html( $offset_name ) . &quot;&lt;/option&gt;&quot;;
+                
+        }
+        $structure[] = '&lt;/optgroup&gt;';
+
</ins><span class="cx">         return join( &quot;\n&quot;, $structure );
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>