Make WordPress Core

Ticket #25555: functions.php.patch

File functions.php.patch, 2.4 KB (added by raubvogel, 13 years ago)

Fix

  • src/wp-includes/functions.php

     
    118118
    119119                $dateformatstring = substr( $dateformatstring, 1, strlen( $dateformatstring ) -1 );
    120120        }
     121
    121122        $timezone_formats = array( 'P', 'I', 'O', 'T', 'Z', 'e' );
    122123        $timezone_formats_re = implode( '|', $timezone_formats );
    123         if ( preg_match( "/$timezone_formats_re/", $dateformatstring ) ) {
    124                 $timezone_string = get_option( 'timezone_string' );
    125                 if ( $timezone_string ) {
    126                         $timezone_object = timezone_open( $timezone_string );
    127                         $date_object = date_create( null, $timezone_object );
    128                         foreach( $timezone_formats as $timezone_format ) {
    129                                 if ( false !== strpos( $dateformatstring, $timezone_format ) ) {
    130                                         $formatted = date_format( $date_object, $timezone_format );
    131                                         $dateformatstring = ' '.$dateformatstring;
    132                                         $dateformatstring = preg_replace( "/([^\\\])$timezone_format/", "\\1" . backslashit( $formatted ), $dateformatstring );
    133                                         $dateformatstring = substr( $dateformatstring, 1, strlen( $dateformatstring ) -1 );
    134                                 }
     124
     125        $timezone_string = get_option( 'timezone_string' );
     126        if ( $timezone_string ) {
     127                $timezone_object = timezone_open( $timezone_string );
     128        }
     129
     130        if ( preg_match( "/$timezone_formats_re/", $dateformatstring ) && $timezone_string ) {
     131                $date_object = date_create( null, $timezone_object );
     132                foreach( $timezone_formats as $timezone_format ) {
     133                        if ( false !== strpos( $dateformatstring, $timezone_format ) ) {
     134                                $formatted = date_format( $date_object, $timezone_format );
     135                                $dateformatstring = ' '.$dateformatstring;
     136                                $dateformatstring = preg_replace( "/([^\\\])$timezone_format/", "\\1" . backslashit( $formatted ), $dateformatstring );
     137                                $dateformatstring = substr( $dateformatstring, 1, strlen( $dateformatstring ) -1 );
    135138                        }
    136139                }
    137140        }
    138         $j = @$datefunc( $dateformatstring, $i );
     141
     142        if ( !$gmt && $timezone_string ) {
     143                $localdateobject = date_create( null, $timezone_object );
     144                date_timestamp_set( $localdateobject, $i );
     145                $j = date_format( $localdateobject, $dateformatstring );
     146        }
     147        else {
     148                $j = @$datefunc( $dateformatstring, $i );
     149        }
     150
    139151        // allow plugins to redo this entirely for languages with untypical grammars
    140152        $j = apply_filters('date_i18n', $j, $req_format, $i, $gmt);
    141153        return $j;