WordPress.org

Make WordPress Core

Changeset 13702


Ignore:
Timestamp:
03/15/10 01:57:36 (4 years ago)
Author:
ryan
Message:

Fix DST/Standard transition display.

File:
1 edited

Legend:

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

    r13663 r13702  
    192192<span> 
    193193    <?php 
     194    // Set TZ so localtime works. 
     195    date_default_timezone_set($tzstring); 
    194196    $now = localtime(time(), true); 
    195197    if ( $now['tm_isdst'] ) 
     
    203205        $found = false; 
    204206        $date_time_zone_selected = new DateTimeZone($tzstring); 
     207        $tz_offset = timezone_offset_get($date_time_zone_selected, date_create()); 
     208        $right_now = time(); 
    205209        foreach ( timezone_transitions_get($date_time_zone_selected) as $tr) { 
    206             if ( $tr['ts'] > time() ) { 
     210            if ( $tr['ts'] > $right_now ) { 
    207211                $found = true; 
    208212                break; 
     
    215219                __('Daylight saving time begins on: <code>%s</code>.') : 
    216220                __('Standard time begins  on: <code>%s</code>.'); 
    217             printf( $message, date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $tr['ts'] ) ); 
     221            // Add the difference between the current offset and the new offset to ts to get the correct transition time from date_i18n(). 
     222            printf( $message, date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $tr['ts'] + ($tz_offset - $tr['offset']) ) ); 
    218223        } else { 
    219224            _e('This timezone does not observe daylight saving time.'); 
    220225        } 
    221226    } 
     227    // Set back to UTC. 
     228    date_default_timezone_set('UTC'); 
    222229    ?> 
    223230    </span> 
Note: See TracChangeset for help on using the changeset viewer.