Date/Time: Eliminate use of date_default_timezone_set() for determining DST status on General Options screen.

Time calculations should not need to rely on manipulating global PHP configuration state.

Props Rarst.
Fixes #46483.

git-svn-id: https://develop.svn.wordpress.org/trunk@45556 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2019-06-20 14:10:44 +00:00
parent e283457e45
commit e9fc71bbbe

View File

@ -252,10 +252,10 @@ if ( empty( $tzstring ) ) { // Create a UTC+- zone if no timezone string exists
<p class="timezone-info">
<span>
<?php
// Set TZ so localtime works.
date_default_timezone_set( $tzstring );
$now = localtime( time(), true );
if ( $now['tm_isdst'] ) {
$now = new DateTime( 'now', new DateTimeZone( $tzstring ) );
$dst = (bool) $now->format( 'I' );
if ( $dst ) {
_e( 'This timezone is currently in daylight saving time.' );
} else {
_e( 'This timezone is currently in standard time.' );
@ -296,8 +296,6 @@ if ( empty( $tzstring ) ) { // Create a UTC+- zone if no timezone string exists
_e( 'This timezone does not observe daylight saving time.' );
}
}
// Set back to UTC.
date_default_timezone_set( 'UTC' );
?>
</span>
</p>