Make WordPress Core

Ticket #8153: bring-T-date-format-back.2.diff

File bring-T-date-format-back.2.diff, 1.4 KB (added by nbachiyski, 15 years ago)
  • wp-includes/functions.php

     
    118118
    119119                $dateformatstring = substr( $dateformatstring, 1, strlen( $dateformatstring ) -1 );
    120120        }
     121        $timezone_formats = array( 'P', 'I', 'O', 'T', 'Z', 'e' );
     122        $timezone_formats_re = implode( '|', $timezone_formats );       
     123        if ( preg_match( "/$timezone_formats_re/", $dateformatstring ) && wp_timezone_supported() ) {
     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                                }
     135                        }                       
     136                }
     137        }
    121138        $j = @$datefunc( $dateformatstring, $i );
    122139        // allow plugins to redo this entirely for languages with untypical grammars
    123140        $j = apply_filters('date_i18n', $j, $req_format, $i, $gmt);