Use GMT dates in legacy API

This commit is contained in:
Claudio Sanches 2016-11-18 16:33:16 -02:00
parent 526a46325f
commit 359e0a5a56
8 changed files with 26 additions and 26 deletions

View File

@ -116,9 +116,9 @@ class WC_API_Orders extends WC_API_Resource {
$order_data = array( $order_data = array(
'id' => $order->get_id(), 'id' => $order->get_id(),
'order_number' => $order->get_order_number(), 'order_number' => $order->get_order_number(),
'created_at' => $this->server->format_datetime( get_gmt_from_date( date( 'Y-m-d H:i:s', $order->get_date_created() ) ) ), 'created_at' => $this->server->format_datetime( $order->get_date_created(), false, true ) ),
'updated_at' => $this->server->format_datetime( get_gmt_from_date( date( 'Y-m-d H:i:s', $order->get_date_modified() ) ) ), 'updated_at' => $this->server->format_datetime( $order->get_date_modified(), false, true ) ),
'completed_at' => $this->server->format_datetime( get_gmt_from_date( date( 'Y-m-d H:i:s', $order->get_date_completed() ) ) ), 'completed_at' => $this->server->format_datetime( $order->get_date_completed(), false, true ) ),
'status' => $order->get_status(), 'status' => $order->get_status(),
'currency' => $order->get_currency(), 'currency' => $order->get_currency(),
'total' => wc_format_decimal( $order->get_total(), 2 ), 'total' => wc_format_decimal( $order->get_total(), 2 ),

View File

@ -267,8 +267,8 @@ class WC_API_Products extends WC_API_Resource {
return array( return array(
'title' => $product->get_name(), 'title' => $product->get_name(),
'id' => $product->get_id(), 'id' => $product->get_id(),
'created_at' => $this->server->format_datetime( $product->get_date_created() ), 'created_at' => $this->server->format_datetime( $product->get_date_created(), false, true ),
'updated_at' => $this->server->format_datetime( $product->get_date_modified() ), 'updated_at' => $this->server->format_datetime( $product->get_date_modified(), false, true ),
'type' => $product->get_type(), 'type' => $product->get_type(),
'status' => $product->get_status(), 'status' => $product->get_status(),
'downloadable' => $product->is_downloadable(), 'downloadable' => $product->is_downloadable(),
@ -347,8 +347,8 @@ class WC_API_Products extends WC_API_Resource {
$variations[] = array( $variations[] = array(
'id' => $variation->get_id(), 'id' => $variation->get_id(),
'created_at' => $this->server->format_datetime( $variation->get_date_created() ), 'created_at' => $this->server->format_datetime( $variation->get_date_created(), false, true ),
'updated_at' => $this->server->format_datetime( $variation->get_date_modified() ), 'updated_at' => $this->server->format_datetime( $variation->get_date_modified(), false, true ),
'downloadable' => $variation->is_downloadable(), 'downloadable' => $variation->is_downloadable(),
'virtual' => $variation->is_virtual(), 'virtual' => $variation->is_virtual(),
'permalink' => $variation->get_permalink(), 'permalink' => $variation->get_permalink(),

View File

@ -150,14 +150,14 @@ class WC_API_Customers extends WC_API_Resource {
$last_order = $customer->get_last_order(); $last_order = $customer->get_last_order();
$customer_data = array( $customer_data = array(
'id' => $customer->get_id(), 'id' => $customer->get_id(),
'created_at' => $this->server->format_datetime( $customer->get_date_created() ), 'created_at' => $this->server->format_datetime( $customer->get_date_created(), false, true ),
'email' => $customer->get_email(), 'email' => $customer->get_email(),
'first_name' => $customer->get_first_name(), 'first_name' => $customer->get_first_name(),
'last_name' => $customer->get_last_name(), 'last_name' => $customer->get_last_name(),
'username' => $customer->get_username(), 'username' => $customer->get_username(),
'role' => $customer->get_role(), 'role' => $customer->get_role(),
'last_order_id' => is_object( $last_order ) ? $last_order->get_id() : null, 'last_order_id' => is_object( $last_order ) ? $last_order->get_id() : null,
'last_order_date' => is_object( $last_order ) ? $this->server->format_datetime( $last_order->get_date_created() ) : null, 'last_order_date' => is_object( $last_order ) ? $this->server->format_datetime( $last_order->get_date_created(), false, true ) : null,
'orders_count' => $customer->get_order_count(), 'orders_count' => $customer->get_order_count(),
'total_spent' => wc_format_decimal( $customer->get_total_spent(), 2 ), 'total_spent' => wc_format_decimal( $customer->get_total_spent(), 2 ),
'avatar_url' => $customer->get_avatar_url(), 'avatar_url' => $customer->get_avatar_url(),

View File

@ -156,9 +156,9 @@ class WC_API_Orders extends WC_API_Resource {
$order_data = array( $order_data = array(
'id' => $order->get_id(), 'id' => $order->get_id(),
'order_number' => $order->get_order_number(), 'order_number' => $order->get_order_number(),
'created_at' => $this->server->format_datetime( get_gmt_from_date( date( 'Y-m-d H:i:s', $order->get_date_created() ) ) ), 'created_at' => $this->server->format_datetime( $order->get_date_created(), false, true ) ),
'updated_at' => $this->server->format_datetime( get_gmt_from_date( date( 'Y-m-d H:i:s', $order->get_date_modified() ) ) ), 'updated_at' => $this->server->format_datetime( $order->get_date_modified(), false, true ) ),
'completed_at' => $this->server->format_datetime( get_gmt_from_date( date( 'Y-m-d H:i:s', $order->get_date_completed() ) ) ), 'completed_at' => $this->server->format_datetime( $order->get_date_completed(), false, true ) ),
'status' => $order->get_status(), 'status' => $order->get_status(),
'currency' => $order->get_currency(), 'currency' => $order->get_currency(),
'total' => wc_format_decimal( $order->get_total(), $dp ), 'total' => wc_format_decimal( $order->get_total(), $dp ),
@ -1534,7 +1534,7 @@ class WC_API_Orders extends WC_API_Resource {
$order_refund = array( $order_refund = array(
'id' => $refund->id, 'id' => $refund->id,
'created_at' => $this->server->format_datetime( get_gmt_from_date( date( 'Y-m-d H:i:s', $refund->get_date_created() ) ) ), 'created_at' => $this->server->format_datetime( $refund->get_date_created(), false, true ) ),
'amount' => wc_format_decimal( $refund->get_amount(), 2 ), 'amount' => wc_format_decimal( $refund->get_amount(), 2 ),
'reason' => $refund->get_reason(), 'reason' => $refund->get_reason(),
'line_items' => $line_items, 'line_items' => $line_items,

View File

@ -684,8 +684,8 @@ class WC_API_Products extends WC_API_Resource {
return array( return array(
'title' => $product->get_name(), 'title' => $product->get_name(),
'id' => $product->get_id(), 'id' => $product->get_id(),
'created_at' => $this->server->format_datetime( $product->get_date_created() ), 'created_at' => $this->server->format_datetime( $product->get_date_created(), false, true ),
'updated_at' => $this->server->format_datetime( $product->get_date_modified() ), 'updated_at' => $this->server->format_datetime( $product->get_date_modified(), false, true ),
'type' => $product->get_type(), 'type' => $product->get_type(),
'status' => $product->get_status(), 'status' => $product->get_status(),
'downloadable' => $product->is_downloadable(), 'downloadable' => $product->is_downloadable(),
@ -769,8 +769,8 @@ class WC_API_Products extends WC_API_Resource {
$variations[] = array( $variations[] = array(
'id' => $variation->get_id(), 'id' => $variation->get_id(),
'created_at' => $this->server->format_datetime( $variation->get_date_created() ), 'created_at' => $this->server->format_datetime( $variation->get_date_created(), false, true ),
'updated_at' => $this->server->format_datetime( $variation->get_date_modified() ), 'updated_at' => $this->server->format_datetime( $variation->get_date_modified(), false, true ),
'downloadable' => $variation->is_downloadable(), 'downloadable' => $variation->is_downloadable(),
'virtual' => $variation->is_virtual(), 'virtual' => $variation->is_virtual(),
'permalink' => $variation->get_permalink(), 'permalink' => $variation->get_permalink(),

View File

@ -134,7 +134,7 @@ class WC_API_Coupons extends WC_API_Resource {
'usage_limit_per_user' => $coupon->get_usage_limit_per_user() ? $coupon->get_usage_limit_per_user() : null, 'usage_limit_per_user' => $coupon->get_usage_limit_per_user() ? $coupon->get_usage_limit_per_user() : null,
'limit_usage_to_x_items' => (int) $coupon->get_limit_usage_to_x_items(), 'limit_usage_to_x_items' => (int) $coupon->get_limit_usage_to_x_items(),
'usage_count' => (int) $coupon->get_usage_count(), 'usage_count' => (int) $coupon->get_usage_count(),
'expiry_date' => $coupon->get_date_expires() ? $this->server->format_datetime( $coupon->get_date_expires() ) : null, 'expiry_date' => $coupon->get_date_expires() ? $this->server->format_datetime( $coupon->get_date_expires(), false, true ) : null,
'enable_free_shipping' => $coupon->get_free_shipping(), 'enable_free_shipping' => $coupon->get_free_shipping(),
'product_category_ids' => array_map( 'absint', (array) $coupon->get_product_categories() ), 'product_category_ids' => array_map( 'absint', (array) $coupon->get_product_categories() ),
'exclude_product_category_ids' => array_map( 'absint', (array) $coupon->get_excluded_product_categories() ), 'exclude_product_category_ids' => array_map( 'absint', (array) $coupon->get_excluded_product_categories() ),

View File

@ -162,9 +162,9 @@ class WC_API_Orders extends WC_API_Resource {
'id' => $order->get_id(), 'id' => $order->get_id(),
'order_number' => $order->get_order_number(), 'order_number' => $order->get_order_number(),
'order_key' => $order->get_order_key(), 'order_key' => $order->get_order_key(),
'created_at' => $this->server->format_datetime( get_gmt_from_date( date( 'Y-m-d H:i:s', $order->get_date_created() ) ) ), 'created_at' => $this->server->format_datetime( $order->get_date_created(), false, true ) ),
'updated_at' => $this->server->format_datetime( get_gmt_from_date( date( 'Y-m-d H:i:s', $order->get_date_modified() ) ) ), 'updated_at' => $this->server->format_datetime( $order->get_date_modified(), false, true ) ),
'completed_at' => $this->server->format_datetime( get_gmt_from_date( date( 'Y-m-d H:i:s', $order->get_date_completed() ) ) ), 'completed_at' => $this->server->format_datetime( $order->get_date_completed(), false, true ) ),
'status' => $order->get_status(), 'status' => $order->get_status(),
'currency' => $order->get_currency(), 'currency' => $order->get_currency(),
'total' => wc_format_decimal( $order->get_total(), $dp ), 'total' => wc_format_decimal( $order->get_total(), $dp ),
@ -1579,7 +1579,7 @@ class WC_API_Orders extends WC_API_Resource {
$order_refund = array( $order_refund = array(
'id' => $refund->id, 'id' => $refund->id,
'created_at' => $this->server->format_datetime( get_gmt_from_date( date( 'Y-m-d H:i:s', $refund->get_date_created() ) ) ), 'created_at' => $this->server->format_datetime( $refund->get_date_created(), false, true ) ),
'amount' => wc_format_decimal( $refund->get_amount(), 2 ), 'amount' => wc_format_decimal( $refund->get_amount(), 2 ),
'reason' => $refund->get_reason(), 'reason' => $refund->get_reason(),
'line_items' => $line_items, 'line_items' => $line_items,

View File

@ -1129,8 +1129,8 @@ class WC_API_Products extends WC_API_Resource {
return array( return array(
'title' => $product->get_name(), 'title' => $product->get_name(),
'id' => $product->get_id(), 'id' => $product->get_id(),
'created_at' => $this->server->format_datetime( $product->get_date_created() ), 'created_at' => $this->server->format_datetime( $product->get_date_created(), false, true ),
'updated_at' => $this->server->format_datetime( $product->get_date_modified() ), 'updated_at' => $this->server->format_datetime( $product->get_date_modified(), false, true ),
'type' => $product->get_type(), 'type' => $product->get_type(),
'status' => $product->get_status(), 'status' => $product->get_status(),
'downloadable' => $product->is_downloadable(), 'downloadable' => $product->is_downloadable(),
@ -1227,8 +1227,8 @@ class WC_API_Products extends WC_API_Resource {
$variations[] = array( $variations[] = array(
'id' => $variation->get_id(), 'id' => $variation->get_id(),
'created_at' => $this->server->format_datetime( $variation->get_date_created() ), 'created_at' => $this->server->format_datetime( $variation->get_date_created(), false, true ),
'updated_at' => $this->server->format_datetime( $variation->get_date_modified() ), 'updated_at' => $this->server->format_datetime( $variation->get_date_modified(), false, true ),
'downloadable' => $variation->is_downloadable(), 'downloadable' => $variation->is_downloadable(),
'virtual' => $variation->is_virtual(), 'virtual' => $variation->is_virtual(),
'permalink' => $variation->get_permalink(), 'permalink' => $variation->get_permalink(),