WordPress.org

Make WordPress Core

Changeset 38804


Ignore:
Timestamp:
10/17/16 08:09:11 (5 months ago)
Author:
swissspidy
Message:

Date/Time: Remove some legacy logic in date_i18n().

Since there's no difference between using date() and gmdate() in WordPress, we can simply use the former in date_i18n() to reduce its complexity.

Adds tests.

Props jdgrimes for initial patch.
Fixes #37910.

Location:
trunk
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/functions.php

    r38686 r38804  
    9292 
    9393    if ( false === $i ) { 
    94         if ( ! $gmt ) 
    95             $i = current_time( 'timestamp' ); 
    96         else 
    97             $i = time(); 
    98         // we should not let date() interfere with our 
    99         // specially computed timestamp 
    100         $gmt = true; 
     94        $i = current_time( 'timestamp', $gmt ); 
    10195    } 
    10296 
     
    107101    $req_format = $dateformatstring; 
    108102 
    109     $datefunc = $gmt? 'gmdate' : 'date'; 
    110  
    111103    if ( ( !empty( $wp_locale->month ) ) && ( !empty( $wp_locale->weekday ) ) ) { 
    112         $datemonth = $wp_locale->get_month( $datefunc( 'm', $i ) ); 
     104        $datemonth = $wp_locale->get_month( date( 'm', $i ) ); 
    113105        $datemonth_abbrev = $wp_locale->get_month_abbrev( $datemonth ); 
    114         $dateweekday = $wp_locale->get_weekday( $datefunc( 'w', $i ) ); 
     106        $dateweekday = $wp_locale->get_weekday( date( 'w', $i ) ); 
    115107        $dateweekday_abbrev = $wp_locale->get_weekday_abbrev( $dateweekday ); 
    116         $datemeridiem = $wp_locale->get_meridiem( $datefunc( 'a', $i ) ); 
    117         $datemeridiem_capital = $wp_locale->get_meridiem( $datefunc( 'A', $i ) ); 
     108        $datemeridiem = $wp_locale->get_meridiem( date( 'a', $i ) ); 
     109        $datemeridiem_capital = $wp_locale->get_meridiem( date( 'A', $i ) ); 
    118110        $dateformatstring = ' '.$dateformatstring; 
    119111        $dateformatstring = preg_replace( "/([^\\\])D/", "\\1" . backslashit( $dateweekday_abbrev ), $dateformatstring ); 
     
    143135        } 
    144136    } 
    145     $j = @$datefunc( $dateformatstring, $i ); 
     137    $j = @date( $dateformatstring, $i ); 
    146138 
    147139    /** 
Note: See TracChangeset for help on using the changeset viewer.