From 432fa1921c6c8ff30546c1d5d67e29e306ea3103 Mon Sep 17 00:00:00 2001 From: Peter Westwood Date: Fri, 5 Nov 2010 11:19:06 +0000 Subject: [PATCH] Restore the functionality of some of the other timezone format modifiers in date_i18n props nbachiyski. git-svn-id: https://develop.svn.wordpress.org/trunk@16203 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/functions.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 27e791af42..f39302f772 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -118,6 +118,23 @@ function date_i18n( $dateformatstring, $unixtimestamp = false, $gmt = false ) { $dateformatstring = substr( $dateformatstring, 1, strlen( $dateformatstring ) -1 ); } + $timezone_formats = array( 'P', 'I', 'O', 'T', 'Z', 'e' ); + $timezone_formats_re = implode( '|', $timezone_formats ); + if ( preg_match( "/$timezone_formats_re/", $dateformatstring ) && wp_timezone_supported() ) { + $timezone_string = get_option( 'timezone_string' ); + if ( $timezone_string ) { + $timezone_object = timezone_open( $timezone_string ); + $date_object = date_create( null, $timezone_object ); + foreach( $timezone_formats as $timezone_format ) { + if ( false !== strpos( $dateformatstring, $timezone_format ) ) { + $formatted = date_format( $date_object, $timezone_format ); + $dateformatstring = ' '.$dateformatstring; + $dateformatstring = preg_replace( "/([^\\\])$timezone_format/", "\\1" . backslashit( $formatted ), $dateformatstring ); + $dateformatstring = substr( $dateformatstring, 1, strlen( $dateformatstring ) -1 ); + } + } + } + } $j = @$datefunc( $dateformatstring, $i ); // allow plugins to redo this entirely for languages with untypical grammars $j = apply_filters('date_i18n', $j, $req_format, $i, $gmt);