WordPress.org

Make WordPress Core

Ticket #8153: localized-dates-options-general.diff

File localized-dates-options-general.diff, 4.2 KB (added by nbachiyski, 5 years ago)
  • wp-includes/functions.php

     
    112112 * @param int $unixtimestamp Unix timestamp 
    113113 * @return string The date, translated if locale specifies it. 
    114114 */ 
    115 function date_i18n( $dateformatstring, $unixtimestamp ) { 
     115function date_i18n( $dateformatstring, $unixtimestamp, $gmt = false ) { 
    116116        global $wp_locale; 
    117117        $i = $unixtimestamp; 
    118118        // Sanity check for PHP 5.1.0- 
    119         if ( -1 == $i ) 
    120                 $i = false; 
     119        if ( intval($i) < 1 ) 
     120                $i = time(); 
    121121 
    122122        if ( ( !empty( $wp_locale->month ) ) && ( !empty( $wp_locale->weekday ) ) ) { 
    123123                $datemonth = $wp_locale->get_month( date( 'm', $i ) ); 
     
    136136 
    137137                $dateformatstring = substr( $dateformatstring, 1, strlen( $dateformatstring ) -1 ); 
    138138        } 
    139         $j = @date( $dateformatstring, $i ); 
     139        $j = $gmt? @gmdate( $dateformatstring, $i ) : @date( $dateformatstring, $i ); 
    140140        return $j; 
    141141} 
    142142 
  • wp-admin/wp-admin.css

     
    13131313} 
    13141314 
    13151315.form-table input.small-text { 
    1316         width: 40px; 
     1316        width: 50px; 
    13171317} 
    13181318 
    13191319#profile-page .form-table textarea { 
  • wp-admin/options-general.php

     
    119119?> 
    120120</select> 
    121121<?php _e('hours') ?> 
    122 <span id="utc-time"><?php printf(__('<abbr title="Coordinated Universal Time">UTC</abbr> time is <code>%s</code>'), gmdate(__('Y-m-d G:i:s'))); ?></span> 
     122<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, gmdate(__('Y-m-d G:i:s'), current_time('timestamp'))); ?></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/> 
    127127<span class="setting-description"><?php _e('Unfortunately, you have to manually update this for Daylight Savings Time. Lame, we know, but will be fixed in the future.'); ?></span> 
     
    148148                        echo " checked='checked'"; 
    149149                        $custom = FALSE; 
    150150                } 
    151                 echo ' /> ' . gmdate( $format, current_time('timestamp') ) . "</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" /> ' . gmdate( get_option('date_format'), current_time('timestamp') ) . "\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"; 
    159159?> 
     
    180180                        echo " checked='checked'"; 
    181181                        $custom = FALSE; 
    182182                } 
    183                 echo ' /> ' . gmdate( $format, current_time('timestamp') ) . "</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" /> ' . gmdate( get_option('time_format'), current_time('timestamp') ) . "\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> 
    191191</td>