@@ -1533,36 +1533,39 @@ function format_date( $date_gmt, $date = null ) {
1533
1533
* relative to now and will convert it to local time using either the
1534
1534
* timezone set in the options table for the blog or the GMT offset.
1535
1535
*
1536
- * @param datetime string
1536
+ * @param datetime string $date_string Date to parse.
1537
1537
*
1538
1538
* @return array( $local_time_string, $gmt_time_string )
1539
1539
*/
1540
- function parse_date ( $ date_string ) {
1540
+ public function parse_date ( $ date_string ) {
1541
1541
$ date_string_info = date_parse ( $ date_string );
1542
1542
if ( is_array ( $ date_string_info ) && 0 === $ date_string_info ['error_count ' ] ) {
1543
1543
// Check if it's already localized. Can't just check is_localtime because date_parse('oppossum') returns true; WTF, PHP.
1544
1544
if ( isset ( $ date_string_info ['zone ' ] ) && true === $ date_string_info ['is_localtime ' ] ) {
1545
- $ dt_local = clone $ dt_utc = new DateTime ( $ date_string );
1545
+ $ dt_utc = new DateTime ( $ date_string );
1546
+ $ dt_local = $ dt_utc ;
1546
1547
$ dt_utc ->setTimezone ( new DateTimeZone ( 'UTC ' ) );
1547
1548
return array (
1548
1549
(string ) $ dt_local ->format ( 'Y-m-d H:i:s ' ),
1549
1550
(string ) $ dt_utc ->format ( 'Y-m-d H:i:s ' ),
1550
1551
);
1551
1552
}
1552
1553
1553
- // It's parseable but no TZ info so assume UTC
1554
- $ dt_local = clone $ dt_utc = new DateTime ( $ date_string , new DateTimeZone ( 'UTC ' ) );
1554
+ // It's parseable but no TZ info so assume UTC.
1555
+ $ dt_utc = new DateTime ( $ date_string , new DateTimeZone ( 'UTC ' ) );
1556
+ $ dt_local = new DateTime ( $ date_string , new DateTimeZone ( 'UTC ' ) );
1555
1557
} else {
1556
- // Could not parse time, use now in UTC
1557
- $ dt_local = clone $ dt_utc = new DateTime ( 'now ' , new DateTimeZone ( 'UTC ' ) );
1558
+ // Could not parse time, use now in UTC.
1559
+ $ dt_utc = new DateTime ( 'now ' , new DateTimeZone ( 'UTC ' ) );
1560
+ $ dt_local = $ dt_utc ;
1558
1561
}
1559
1562
1560
1563
$ dt_local ->setTimezone ( wp_timezone () );
1561
1564
1562
1565
return array (
1563
1566
(string ) $ dt_local ->format ( 'Y-m-d H:i:s ' ),
1564
1567
(string ) $ dt_utc ->format ( 'Y-m-d H:i:s ' ),
1565
- );
1568
+ );
1566
1569
}
1567
1570
1568
1571
// Load the functions.php file for the current theme to get its post formats, CPTs, etc.
0 commit comments