Make WordPress Core


Ignore:
Timestamp:
11/17/2008 09:31:46 PM (16 years ago)
Author:
ryan
Message:

date_i18n() fixes. Props nbachiyski. fixes #8153

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.