Optimize timezone dropdown creation. Props sambauers. fixes #10125 for trunk

git-svn-id: http://svn.automattic.com/wordpress/trunk@11597 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan
2009-06-18 17:40:40 +00:00
parent 947f1ce2c6
commit b37b56a339
2 changed files with 149 additions and 97 deletions

View File

@@ -157,7 +157,7 @@ if (empty($tzstring)) { // set the Etc zone if no timezone string exists
<span class="description"><?php _e('Choose a city in the same timezone as you.'); ?></span>
<br />
<span>
<?php if (get_option('timezone_string')) : ?>
<?php if ($tzstring) : ?>
<?php
$now = localtime(time(),true);
if ($now['tm_isdst']) _e('This timezone is currently in daylight savings time.');
@@ -165,11 +165,11 @@ if (empty($tzstring)) { // set the Etc zone if no timezone string exists
?>
<br />
<?php
if (function_exists('timezone_transitions_get') && $tzstring) {
if (function_exists('timezone_transitions_get')) {
$dateTimeZoneSelected = new DateTimeZone($tzstring);
foreach (timezone_transitions_get($dateTimeZoneSelected) as $tr) {
if ($tr['ts'] > time()) {
$found = true;
$found = true;
break;
}
}
@@ -179,10 +179,7 @@ if (empty($tzstring)) { // set the Etc zone if no timezone string exists
$message = $tr['isdst'] ?
__('Daylight savings time begins on: <code>%s</code>.') :
__('Standard time begins on: <code>%s</code>.');
$tz = new DateTimeZone($tzstring);
$d = new DateTime( "@{$tr['ts']}" );
$d->setTimezone($tz);
printf( $message, date_i18n(get_option('date_format').' '.get_option('time_format'), $d->format('U') ) );
printf( $message, date_i18n(get_option('date_format').' '.get_option('time_format'), $tr['ts'] ) );
} else {
_e('This timezone does not observe daylight savings time.');
}