WordPress.org

Make WordPress Core

Changeset 10757


Ignore:
Timestamp:
03/10/2009 04:14:50 PM (9 years ago)
Author:
ryan
Message:

Show DST info. Map old offest to Etc zones. Props Otto42. see #3962

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/options-general.php

    r10753 r10757  
    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>
     
    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/>
  • trunk/wp-includes/functions.php

    r10756 r10757  
    31093109        $i++;
    31103110    }
    3111 
     3111   
    31123112    asort($zonen);
    31133113    $structure = '';
     
    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    }
Note: See TracChangeset for help on using the changeset viewer.