WordPress.org

Make WordPress Core

Changeset 9742


Ignore:
Timestamp:
11/17/08 21:31:46 (5 years ago)
Author:
ryan
Message:

date_i18n() fixes. Props nbachiyski. fixes #8153

Location:
trunk
Files:
2 edited

Legend:

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

    r9647 r9742  
    122122<span id="utc-time"><?php printf(__('<abbr title="Coordinated Universal Time">UTC</abbr> time is <code>%s</code>'), date_i18n(__('Y-m-d G:i:s'), false, 'gmt')); ?></span> 
    123123<?php if ($current_offset) : ?> 
    124     <span id="local-time"><?php printf(__('UTC %1$s is <code>%2$s</code>'), $current_offset_name, date_i18n(__('Y-m-d G:i:s'), current_time('timestamp'), 'gmt')); ?></span> 
     124    <span id="local-time"><?php printf(__('UTC %1$s is <code>%2$s</code>'), $current_offset_name, date_i18n(__('Y-m-d G:i:s'))); ?></span> 
    125125<?php endif; ?> 
    126126<br/> 
     
    149149            $custom = FALSE; 
    150150        } 
    151         echo ' /> ' . date_i18n( $format, current_time('timestamp'), 'gmt' ) . "</label><br />\n"; 
     151        echo ' /> ' . date_i18n( $format ) . "</label><br />\n"; 
    152152    } 
    153153 
    154154    echo '  <label><input type="radio" name="date_format" id="date_format_custom_radio" value="\c\u\s\t\o\m"'; 
    155155    checked( $custom, TRUE ); 
    156     echo '/> ' . __('Custom:') . ' </label><input type="text" name="date_format_custom" value="' . attribute_escape( get_option('date_format') ) . '" class="small-text" /> ' . date_i18n( get_option('date_format'), current_time('timestamp'), 'gmt' ) . "\n"; 
     156    echo '/> ' . __('Custom:') . ' </label><input type="text" name="date_format_custom" value="' . attribute_escape( get_option('date_format') ) . '" class="small-text" /> ' . date_i18n( get_option('date_format') ) . "\n"; 
    157157 
    158158    echo "\t<p>" . __('<a href="http://codex.wordpress.org/Formatting_Date_and_Time">Documentation on date formatting</a>. Click "Save Changes" to update sample output.') . "</p>\n"; 
     
    181181            $custom = FALSE; 
    182182        } 
    183         echo ' /> ' . date_i18n( $format, current_time('timestamp'), 'gmt' ) . "</label><br />\n"; 
     183        echo ' /> ' . date_i18n( $format ) . "</label><br />\n"; 
    184184    } 
    185185 
    186186    echo '  <label><input type="radio" name="time_format" id="time_format_custom_radio" value="\c\u\s\t\o\m"'; 
    187187    checked( $custom, TRUE ); 
    188     echo '/> ' . __('Custom:') . ' </label><input type="text" name="time_format_custom" value="' . attribute_escape( get_option('time_format') ) . '" class="small-text" /> ' . date_i18n( get_option('time_format'), current_time('timestamp'), 'gmt' ) . "\n"; 
     188    echo '/> ' . __('Custom:') . ' </label><input type="text" name="time_format_custom" value="' . attribute_escape( get_option('time_format') ) . '" class="small-text" /> ' . date_i18n( get_option('time_format') ) . "\n"; 
    189189?> 
    190190    </fieldset> 
  • trunk/wp-includes/functions.php

    r9740 r9742  
    117117    $i = $unixtimestamp; 
    118118    // Sanity check for PHP 5.1.0- 
    119     if ( false === $i || intval($i) < 0 ) 
    120         $i = time(); 
     119    if ( false === $i || intval($i) < 0 ) { 
     120        if ( ! $gmt ) 
     121            $i = current_time( 'timestamp' ); 
     122        else 
     123            $i = time(); 
     124        // we should not let date() interfere with our 
     125        // specially computed timestamp 
     126        $gmt = true; 
     127    } 
     128 
     129    $datefunc = $gmt? 'gmdate' : 'date'; 
    121130 
    122131    if ( ( !empty( $wp_locale->month ) ) && ( !empty( $wp_locale->weekday ) ) ) { 
    123         $datemonth = $wp_locale->get_month( date( 'm', $i ) ); 
     132        $datemonth = $wp_locale->get_month( $datefunc( 'm', $i ) ); 
    124133        $datemonth_abbrev = $wp_locale->get_month_abbrev( $datemonth ); 
    125         $dateweekday = $wp_locale->get_weekday( date( 'w', $i ) ); 
     134        $dateweekday = $wp_locale->get_weekday( $datefunc( 'w', $i ) ); 
    126135        $dateweekday_abbrev = $wp_locale->get_weekday_abbrev( $dateweekday ); 
    127         $datemeridiem = $wp_locale->get_meridiem( date( 'a', $i ) ); 
    128         $datemeridiem_capital = $wp_locale->get_meridiem( date( 'A', $i ) ); 
     136        $datemeridiem = $wp_locale->get_meridiem( $datefunc( 'a', $i ) ); 
     137        $datemeridiem_capital = $wp_locale->get_meridiem( $datefunc( 'A', $i ) ); 
    129138        $dateformatstring = ' '.$dateformatstring; 
    130139        $dateformatstring = preg_replace( "/([^\\\])D/", "\\1" . backslashit( $dateweekday_abbrev ), $dateformatstring ); 
     
    137146        $dateformatstring = substr( $dateformatstring, 1, strlen( $dateformatstring ) -1 ); 
    138147    } 
    139     $j = $gmt? @gmdate( $dateformatstring, $i ) : @date( $dateformatstring, $i ); 
     148    $j = @$datefunc( $dateformatstring, $i ); 
    140149    return $j; 
    141150} 
Note: See TracChangeset for help on using the changeset viewer.