From 1b90296bbace11d572e17e3d33b6e6aff771e334 Mon Sep 17 00:00:00 2001 From: Peter Fabian Date: Mon, 25 Feb 2019 20:05:25 +0100 Subject: [PATCH] Updated timezone handling to be in line with other WC code. --- .../class-wc-admin-reports-orders-stats-data-store.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/plugins/woocommerce-admin/includes/data-stores/class-wc-admin-reports-orders-stats-data-store.php b/plugins/woocommerce-admin/includes/data-stores/class-wc-admin-reports-orders-stats-data-store.php index b79cb59ea4a..0468fccac43 100644 --- a/plugins/woocommerce-admin/includes/data-stores/class-wc-admin-reports-orders-stats-data-store.php +++ b/plugins/woocommerce-admin/includes/data-stores/class-wc-admin-reports-orders-stats-data-store.php @@ -525,9 +525,8 @@ class WC_Admin_Reports_Orders_Stats_Data_Store extends WC_Admin_Reports_Data_Sto $second_order = isset( $oldest_orders[1] ) ? $oldest_orders[1] : false; $excluded_statuses = self::get_excluded_report_order_statuses(); - $local_tz = new DateTimeZone( wc_timezone_string() ); // Order is older than previous first order. - if ( $order->get_date_created() < new WC_DateTime( $first_order->date_created, $local_tz ) && + if ( $order->get_date_created() < wc_string_to_datetime( $first_order->date_created ) && ! in_array( $order->get_status(), $excluded_statuses, true ) ) { self::set_customer_first_order( $customer_id, $order->get_id() ); @@ -538,8 +537,8 @@ class WC_Admin_Reports_Orders_Stats_Data_Store extends WC_Admin_Reports_Data_Sto $is_first_order = (int) $order->get_id() === (int) $first_order->order_id; // Order date has changed and next oldest is now the first order. $date_change = $second_order && - $order->get_date_created() > new WC_DateTime( $first_order->date_created, $local_tz ) && - new WC_DateTime( $second_order->date_created, $local_tz ) < $order->get_date_created(); + $order->get_date_created() > wc_string_to_datetime( $first_order->date_created ) && + wc_string_to_datetime( $second_order->date_created ) < $order->get_date_created(); // Status has changed to an excluded status and next oldest order is now the first order. $status_change = $second_order && in_array( $order->get_status(), $excluded_statuses, true );