Date/Time: Use `wp_date()` to display the correct time of the next DST transition in Timezone setting on General Settings screen.
Props Rarst, autotutorial. Merges [47073] to the 5.3 branch. Fixes #49038. Built from https://develop.svn.wordpress.org/branches/5.3@47127 git-svn-id: http://core.svn.wordpress.org/branches/5.3@46927 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
b1e2b6174d
commit
c7963618ca
|
@ -276,34 +276,20 @@ if ( empty( $tzstring ) ) { // Create a UTC+- zone if no timezone string exists
|
|||
?>
|
||||
<br />
|
||||
<?php
|
||||
$allowed_zones = timezone_identifiers_list();
|
||||
if ( in_array( $tzstring, timezone_identifiers_list() ) ) {
|
||||
$transitions = timezone_transitions_get( timezone_open( $tzstring ), time() );
|
||||
|
||||
if ( in_array( $tzstring, $allowed_zones ) ) {
|
||||
$found = false;
|
||||
$date_time_zone_selected = new DateTimeZone( $tzstring );
|
||||
$tz_offset = timezone_offset_get( $date_time_zone_selected, date_create() );
|
||||
$right_now = time();
|
||||
foreach ( timezone_transitions_get( $date_time_zone_selected ) as $tr ) {
|
||||
if ( $tr['ts'] > $right_now ) {
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $found ) {
|
||||
// 0 index is the state at current time, 1 index is the next transition, if any.
|
||||
if ( ! empty( $transitions[1] ) ) {
|
||||
echo ' ';
|
||||
$message = $tr['isdst'] ?
|
||||
$message = $transitions[1]['isdst'] ?
|
||||
/* translators: %s: Date and time. */
|
||||
__( 'Daylight saving time begins on: %s.' ) :
|
||||
/* translators: %s: Date and time. */
|
||||
__( 'Standard time begins on: %s.' );
|
||||
// Add the difference between the current offset and the new offset to ts to get the correct transition time from date_i18n().
|
||||
printf(
|
||||
$message,
|
||||
'<code>' . date_i18n(
|
||||
__( 'F j, Y' ) . ' ' . __( 'g:i a' ),
|
||||
$tr['ts'] + ( $tz_offset - $tr['offset'] )
|
||||
) . '</code>'
|
||||
'<code>' . wp_date( __( 'F j, Y' ) . ' ' . __( 'g:i a' ), $transitions[1]['ts'] ) . '</code>'
|
||||
);
|
||||
} else {
|
||||
_e( 'This timezone does not observe daylight saving time.' );
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.3.3-alpha-47126';
|
||||
$wp_version = '5.3.3-alpha-47127';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue