Make WordPress Core

Ticket #3962: timezone-dstinfo.diff

File timezone-dstinfo.diff, 3.5 KB (added by Otto42, 16 years ago)

Same as etc patch, with added DST info

  • wp-admin/options-general.php

     
    133133<?php
    134134else: // looks like we can do nice timezone selection!
    135135$current_offset = get_option('gmt_offset');
     136$tzstring = get_option('timezone_string');
     137if (empty($tzstring)) { // set the Etc zone if no timezone string exists
     138        if ($current_offset < 0) $offnum = ceil($current_offset);
     139        else $offnum = floor($current_offset);
     140        $tzstring = 'Etc/GMT' . (($offnum >= 0) ? '+' : '') . $offnum;
     141}
    136142?>
    137143<th scope="row"><label for="timezone_string"><?php _e('Timezone') ?></label></th>
    138144<td>
    139145
    140146<select id="timezone_string" name="timezone_string">
    141 <?php echo wp_timezone_choice(get_option('timezone_string')); ?>
     147<?php echo wp_timezone_choice($tzstring); ?>
    142148</select>
    143149
    144150<span id="utc-time"><?php printf(__('<abbr title="Coordinated Universal Time">UTC</abbr> time is <code>%s</code>'), date_i18n(__('Y-m-d G:i:s'), false, 'gmt')); ?></span>
    145151<?php if (get_option('timezone_string')) : ?>
    146         <span id="local-time"><?php printf(__('Current time in %1$s is <code>%2$s</code>'), get_option('timezone_string'), date_i18n(__('Y-m-d G:i:s'))); ?></span>
     152        <span id="local-time"><?php printf(__('Current time in %1$s is <code>%2$s</code>'), get_option('timezone_string'), date_i18n(__('Y-m-d G:i:s'))); ?>
     153        <br />
     154        <?php
     155        _e('This timezone is currently in ');
     156        $now = localtime(time(),true);
     157        if ($now['tm_isdst']) _e('daylight savings');
     158        else _e('standard');
     159        _e(' time.');
     160        ?>
     161        <br />
     162        <?php
     163        if (function_exists('timezone_transitions_get') && $tzstring) {
     164                $dateTimeZoneSelected = new DateTimeZone($tzstring);
     165                foreach (timezone_transitions_get($dateTimeZoneSelected) as $tr) {
     166                        if ($tr['ts'] > time()) {
     167                                $found = true;
     168                                break;
     169                        }
     170                }
     171       
     172                if ($found) {
     173                        _e('This timezone switches to ');
     174                        $tr['isdst'] ? _e('daylight savings time') : _e('standard time');
     175                        _e(' on: ');
     176                        $tz = new DateTimeZone($tzstring);
     177                        $d = new DateTime( "@{$tr['ts']}" );
     178                        $d->setTimezone($tz);
     179                        echo date_i18n(__('Y-m-d \a\t g:i a T'),$d->format('U'));
     180                } else {
     181                        _e('This timezone does not observe daylight savings time.');
     182                }
     183        }
     184        ?>
     185        </span>
    147186<?php endif; ?>
    148187<br/>
    149188<span class="setting-description"><?php _e('Choose a city in the same timezone as you.'); ?></span>
  • wp-includes/functions.php

     
    31043104                $zonen[$i]['subcity'] = isset($zone[2]) ? $zone[2] : '';
    31053105                $i++;
    31063106        }
    3107 
     3107       
    31083108        asort($zonen);
    31093109        $structure = '';
    31103110        $pad = '&nbsp;&nbsp;&nbsp;';
     
    31333133                        if ( !empty($subcity) ) {
    31343134                                $city = $city . '/'. $subcity;
    31353135                        }
    3136                         $structure .= "\t<option ".((($continent.'/'.$city)==$selectedzone)?'selected="selected "':'')." value=\"".($continent.'/'.$city)."\">$pad".str_replace('_',' ',$city)."</option>\n"; //Timezone
     3136                        $structure .= "\t<option ".((($continent.'/'.$city)==$selectedzone)?'selected="selected"':'')." value=\"".($continent.'/'.$city)."\">$pad".str_replace('_',' ',$city)."</option>\n"; //Timezone
    31373137                } else {
    3138                         $structure .= "<option ".(($continent==$selectedzone)?'selected="selected "':'')." value=\"".$continent."\">".$continent."</option>\n"; //Timezone
     3138                        $structure .= "<option ".(($continent==$selectedzone)?'selected="selected"':'')." value=\"".$continent."\">".$continent."</option>\n"; //Timezone
    31393139                }
    31403140        }
    31413141