Changeset 43387
- Timestamp:
- 07/03/2018 03:58:58 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/functions.php
r43384 r43387 137 137 $dateformatstring = preg_replace( "/([^\\\])$timezone_format/", "\\1" . backslashit( $formatted ), $dateformatstring ); 138 138 $dateformatstring = substr( $dateformatstring, 1, strlen( $dateformatstring ) - 1 ); 139 } 140 } 141 } else { 142 $offset = get_option( 'gmt_offset' ); 143 foreach ( $timezone_formats as $timezone_format ) { 144 if ( 'I' === $timezone_format ) { 145 continue; 146 } 147 148 if ( false !== strpos( $dateformatstring, $timezone_format ) ) { 149 if ( 'Z' === $timezone_format ) { 150 $formatted = (string) ( $offset * HOUR_IN_SECONDS ); 151 } else { 152 $prefix = ''; 153 $hours = (int) $offset; 154 $separator = ''; 155 $minutes = abs( ( $offset - $hours ) * 60 ); 156 157 if ( 'T' === $timezone_format ) { 158 $prefix = 'GMT'; 159 } elseif ( 'e' === $timezone_format || 'P' === $timezone_format ) { 160 $separator = ':'; 161 } 162 163 $formatted = sprintf( '%s%+03d%s%02d', $prefix, $hours, $separator, $minutes ); 164 } 165 166 $dateformatstring = ' ' . $dateformatstring; 167 $dateformatstring = preg_replace( "/([^\\\])$timezone_format/", "\\1" . backslashit( $formatted ), $dateformatstring ); 168 $dateformatstring = substr( $dateformatstring, 1 ); 139 169 } 140 170 } -
trunk/tests/phpunit/tests/date/dateI18n.php
r42343 r43387 68 68 $this->assertEquals( '2012-12-01 00:00:00 CST -06:00 America/Regina', date_i18n( 'Y-m-d H:i:s T P e', strtotime( '2012-12-01 00:00:00' ) ) ); 69 69 } 70 71 /** 72 * @ticket 34835 73 */ 74 public function test_gmt_offset_should_output_correct_timezone() { 75 $timezone_formats = 'P I O T Z e'; 76 $timezone_string = 'America/Regina'; 77 $datetimezone = new DateTimeZone( $timezone_string ); 78 update_option( 'timezone_string', '' ); 79 $offset = $datetimezone->getOffset( new DateTime() ) / 3600; 80 update_option( 'gmt_offset', $offset ); 81 $datetime = new DateTime( 'now', $datetimezone ); 82 $datetime = new DateTime( $datetime->format( 'P' ) ); 83 84 $this->assertEquals( $datetime->format( $timezone_formats ), date_i18n( $timezone_formats ) ); 85 } 70 86 }
Note: See TracChangeset
for help on using the changeset viewer.