Changeset 35284
- Timestamp:
- 10/20/2015 06:07:45 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/formatting.php
r35252 r35284 612 612 . '(?:]]>)?'; // End of comment. If not found, match all input. 613 613 614 $escaped = 614 $escaped = 615 615 '(?=' // Is the element escaped? 616 616 . '!--' … … 2588 2588 if ( $tz ) { 2589 2589 $datetime = date_create( $string, new DateTimeZone( $tz ) ); 2590 if ( ! $datetime ) 2590 if ( ! $datetime ) { 2591 2591 return gmdate( $format, 0 ); 2592 } 2592 2593 $datetime->setTimezone( new DateTimeZone( 'UTC' ) ); 2593 2594 $string_gmt = $datetime->format( $format ); 2594 2595 } else { 2595 if ( ! preg_match( '#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches ) ) 2596 return gmdate( $format, 0 ); 2596 if ( ! preg_match( '#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches ) ) { 2597 $datetime = strtotime( $string ); 2598 if ( false === $datetime ) { 2599 return gmdate( $format, 0 ); 2600 } 2601 return gmdate( $format, $datetime ); 2602 } 2597 2603 $string_time = gmmktime( $matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1] ); 2598 2604 $string_gmt = gmdate( $format, $string_time - get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); … … 3877 3883 * This is similar to `array_walk_recursive()` but acts upon objects too. 3878 3884 * 3879 * @since 4.4.0 3880 * 3885 * @since 4.4.0 3886 * 3881 3887 * @param mixed $value The array, object, or scalar. 3882 * @param callable $ functionThe function to map onto $value.3888 * @param callable $callback The function to map onto $value. 3883 3889 * @return The value with the callback applied to all non-arrays and non-objects inside it. 3884 3890 */ -
trunk/tests/phpunit/tests/formatting/date.php
r25002 r35284 48 48 $this->assertEquals( $gmt, get_gmt_from_date( $local ) ); 49 49 } 50 51 /** 52 * @ticket 34279 53 */ 54 function test_get_date_and_time_from_gmt_no_timezone() { 55 $gmt = $local = '2012-01-01 12:34:56'; 56 $this->assertEquals( $gmt, get_date_from_gmt( $local ) ); 57 } 58 59 /** 60 * @ticket 34279 61 */ 62 function test_get_gmt_from_date_no_timezone() { 63 $gmt = '2012-12-01 00:00:00'; 64 $date = '2012-12-01'; 65 $this->assertEquals( $gmt, get_gmt_from_date( $date ) ); 66 } 67 68 /** 69 * @ticket 34279 70 */ 71 function test_get_gmt_from_date_short_date() { 72 update_option( 'timezone_string', 'Europe/London' ); 73 $local = '2012-12-01'; 74 $gmt = '2012-12-01 00:00:00'; 75 $this->assertEquals( $gmt, get_gmt_from_date( $local ) ); 76 } 77 78 /** 79 * @ticket 34279 80 */ 81 function test_get_gmt_from_date_string_date() { 82 update_option( 'timezone_string', 'Europe/London' ); 83 $local = 'now'; 84 $gmt = gmdate( 'Y-m-d H:i:s', strtotime( 'now' ) ); 85 $this->assertEquals( $gmt, get_gmt_from_date( $local ) ); 86 } 87 88 /** 89 * @ticket 34279 90 */ 91 function test_get_gmt_from_date_string_date_no_timezone() { 92 $local = 'now'; 93 $gmt = gmdate( 'Y-m-d H:i:s', strtotime( 'now' ) ); 94 $this->assertEquals( $gmt, get_gmt_from_date( $local ) ); 95 } 50 96 }
Note: See TracChangeset
for help on using the changeset viewer.