From 1aaf11947eff09df825706e602c5fc654ef80110 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 23 Aug 2019 02:15:55 +0000 Subject: [PATCH] Date/Time: Simplify the date comparing logic in `WP_Community_Events::trim_events()`. The Events API returns event date without timezone information, so trying to parse it into a timestamp and compare to a WP timestamp is pointless. Props Rarst. Fixes #47463. Built from https://develop.svn.wordpress.org/trunk@45886 git-svn-id: http://core.svn.wordpress.org/trunk@45697 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/class-wp-community-events.php | 9 +++++---- wp-includes/version.php | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/wp-admin/includes/class-wp-community-events.php b/wp-admin/includes/class-wp-community-events.php index 2237ab34e4..ac77cb7482 100644 --- a/wp-admin/includes/class-wp-community-events.php +++ b/wp-admin/includes/class-wp-community-events.php @@ -402,8 +402,8 @@ class WP_Community_Events { */ protected function trim_events( $response_body ) { if ( isset( $response_body['events'] ) ) { - $wordcamps = array(); - $current_timestamp = current_time( 'timestamp' ); + $wordcamps = array(); + $today = current_time( 'Y-m-d' ); foreach ( $response_body['events'] as $key => $event ) { /* @@ -415,9 +415,10 @@ class WP_Community_Events { continue; } - $event_timestamp = strtotime( $event['date'] ); + // We don't get accurate time with timezone from API, so we only take the date part (Y-m-d). + $event_date = substr( $event['date'], 0, 10 ); - if ( $current_timestamp > $event_timestamp && ( $current_timestamp - $event_timestamp ) > DAY_IN_SECONDS ) { + if ( $today > $event_date ) { unset( $response_body['events'][ $key ] ); } } diff --git a/wp-includes/version.php b/wp-includes/version.php index 2eedca2522..336fe5dec1 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.3-alpha-45885'; +$wp_version = '5.3-alpha-45886'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.