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

File bring-T-date-format-back.2.diff, 1.4 KB (added by nbachiyski, 3 years ago)
Line 
1Index: wp-includes/functions.php
2===================================================================
3--- wp-includes/functions.php   (revision 15788)
4+++ wp-includes/functions.php   (working copy)
5@@ -118,6 +118,23 @@
6 
7                $dateformatstring = substr( $dateformatstring, 1, strlen( $dateformatstring ) -1 );
8        }
9+       $timezone_formats = array( 'P', 'I', 'O', 'T', 'Z', 'e' );
10+       $timezone_formats_re = implode( '|', $timezone_formats );       
11+       if ( preg_match( "/$timezone_formats_re/", $dateformatstring ) && wp_timezone_supported() ) {
12+               $timezone_string = get_option( 'timezone_string' );
13+               if ( $timezone_string ) {
14+                       $timezone_object = timezone_open( $timezone_string );
15+                       $date_object = date_create( null, $timezone_object );
16+                       foreach( $timezone_formats as $timezone_format ) {
17+                               if ( false !== strpos( $dateformatstring, $timezone_format ) ) {
18+                                       $formatted = date_format( $date_object, $timezone_format );
19+                                       $dateformatstring = ' '.$dateformatstring;
20+                                       $dateformatstring = preg_replace( "/([^\\\])$timezone_format/", "\\1" . backslashit( $formatted ), $dateformatstring );
21+                                       $dateformatstring = substr( $dateformatstring, 1, strlen( $dateformatstring ) -1 );
22+                               }
23+                       }                       
24+               }
25+       }
26        $j = @$datefunc( $dateformatstring, $i );
27        // allow plugins to redo this entirely for languages with untypical grammars
28        $j = apply_filters('date_i18n', $j, $req_format, $i, $gmt);