godaddy-wordpress / woocommerce-memberships-rest-api-docs

WooCommerce Memberships REST API Documentation
https://godaddy-wordpress.github.io/woocommerce-memberships-rest-api-docs/
Other
10 stars 4 forks source link

Wrong format for local datetime #10

Closed KitaitiMakoto closed 3 years ago

KitaitiMakoto commented 4 years ago

Bug Description According to API reference, User Membership object has some datetime fields in the local time zone, such as date_created, start_date, end_date and so on. But those fields always have time zone indicator +00:00 that indicates UTC(GMT) time zone.

Response in example for, for instance, POST http://example.com/api/wc/v3/memberships/members has:

{
    // ...
    "date_created": "2019-04-17T17:51:02+00:00",
    "date_created_gmt": "2019-04-17T09:51:02+00:00",
    // ...
}

Here, date_created should have local time zone indicator but actually has +00:00. The value differs from date_created_gmt so it should not be in +00:00 time zone. My site with your plugin behaves like this.

Could you append right time zone(+08:00 for above example) or remove them?

Environments

unfulvio commented 4 years ago

Thanks for pointing this out @KitaitiMakoto it looks like we should omit the timezone information though, to be consistent with other WC API items that output datetime strings (WC orders and products do not seem to include the timezone indication in the string); the local timezone can be inferred from the WordPress REST API or the WC Status route.

unfulvio commented 4 years ago

I noticed how the timezone component is included in Memberships' own API docs. I need to check with my team about this change and the correct output. Meanwhile if you have more questions or feedback for us you are also very welcome to reach us over https://www.skyverge.com/contact/ -- thank you!

KitaitiMakoto commented 4 years ago

Thank you for the reply and pointing contact form! I will wait for this problem fixed.

unfulvio commented 4 years ago

どういたしまして!もんだいをおわびします。

KitaitiMakoto commented 3 years ago

Does closing mean this was fixed in the latest version?

unfulvio-godaddy commented 3 years ago

hey @KitaitiMakoto for now we updated the docs to reflect the output that Memberships will give.

The plugin isn't using yet dates with regards to timezone unfortunately, the string its date functions return don't assume they will include a timezone information, nor there are methods to return DateTime objects, which would make timezones less ambiguous.

The API was designed to reflect the same output. The dates would be in UTC and the local dates, while presenting the time in UTC, they have an offset that reflects the current WP site timezone (the information should be retrievable from an option).

There's certainly the intention to change this further and move towards well formed DateTime objects and have more consistent API responses, but it's a breaking change that we can push perhaps with a new version of the API in the future.

If you have further feedback or questions for our team, we'd be very happy to address it: https://www.skyverge.com/contact/

Thank you!

unfulvio-godaddy commented 3 years ago

related PR https://github.com/skyverge/woocommerce-memberships-rest-api-docs/pull/12