[wp-trac] [WordPress Trac] #49038: Timezone setting does not display correct time of next DST transition
WordPress Trac
noreply at wordpress.org
Thu Dec 19 17:33:17 UTC 2019
#49038: Timezone setting does not display correct time of next DST transition
--------------------------+------------------------------
Reporter: autotutorial | Owner: Rarst
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: Awaiting Review
Component: Date/Time | Version:
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------+------------------------------
Comment (by autotutorial):
{{{#!php
<?php
$tz_offset = timezone_offset_get( $date_time_zone_selected,
date_create( 'now', $date_time_zone_selected ) );
$right_now = time();
foreach ( timezone_transitions_get(
$date_time_zone_selected ) as $tr ) {
if ( $tr['ts'] > $right_now ) {
$found = true;
break;
}
}
if ( $found ) {
echo ' ';
$message = $tr['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'] + ($tr['offset'] -
$tz_offset )
}}}
thanks for the explanation if it is in a timezone it turns into UTC and
will be displayed in timezone only as output (obviously if it is a
convertible date).
I created a code improvement I can't create the patch, can you create it?
calculating the current offset in the timezone selected in general
settings if they are in daylight savings time the variations have the same
value, I make a subtraction and give the result which can be 0.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/49038#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list