[wp-trac] [WordPress Trac] #40136: REST API: Issues with dates and DST (was: Failing rest-api test test_empty_post_date_gmt_shimmed_using_post_date)
WordPress Trac
noreply at wordpress.org
Tue Mar 14 16:16:38 UTC 2017
#40136: REST API: Issues with dates and DST
---------------------------------------+-----------------------
Reporter: afercia | Owner: jnylen0
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: 4.7.4
Component: REST API | Version: 4.7.3
Severity: major | Resolution:
Keywords: needs-refresh needs-patch | Focuses:
---------------------------------------+-----------------------
Changes (by jnylen0):
* status: reopened => assigned
* version: => 4.7.3
* milestone: Awaiting Review => 4.7.4
* keywords: needs-refresh needs-patch dev-feedback => needs-refresh needs-
patch
Old description:
> Not sure why this test fails for some people and doesn't fail for other
> people. Probably related to difference in Day Saving Time across the
> world (currently, North America is already in DST, Europe not).
>
> For me (GMT+1 and currently no DST here), it is failing:
>
> {{{
> 1)
> WP_Test_REST_Posts_Controller::test_empty_post_date_gmt_shimmed_using_post_date
> Failed asserting that two strings are equal.
> --- Expected
> +++ Actual
> @@ @@
> -'2016-02-23T18:00:00'
> +'2016-02-23T17:00:00'
> }}}
>
> As pointed out by @nerrad [https://wordpress.slack.com/archives/core-
> restapi/p1489343561764369 on Slack] the hour difference expected in the
> test actually differs depending on DST.
>
> Test was introduced in [40115].
New description:
''Edit: As indicated by @nerrad below, the original test was correct and
this is a problem with the API logic.''
Not sure why this test fails for some people and doesn't fail for other
people. Probably related to difference in Day Saving Time across the world
(currently, North America is already in DST, Europe not).
For me (GMT+1 and currently no DST here), it is failing:
{{{
1)
WP_Test_REST_Posts_Controller::test_empty_post_date_gmt_shimmed_using_post_date
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'2016-02-23T18:00:00'
+'2016-02-23T17:00:00'
}}}
As pointed out by @nerrad [https://wordpress.slack.com/archives/core-
restapi/p1489343561764369 on Slack] the hour difference expected in the
test actually differs depending on DST.
Test was introduced in [40115].
--
Comment:
Yes, I agree this is a problem, and while there are currently no failing
tests as a result of [40284], we definitely want to get this fixed in
4.7.4 :(
Something similar to the existing `wp_timezone_override_offset` code
should work, but using the actual date instead of the current date:
https://core.trac.wordpress.org/browser/tags/4.7.2/src/wp-
includes/functions.php?marks=4504,4505,4509#L4490
Because WP doesn't store dates in UTC for drafts, there will still be
cases where it's impossible to determine a correct `date_gmt` based on the
`date` (there are brief windows where the same date can occur twice in
timezones with DST, and we will just have to pick one of the two
corresponding UTC dates).
--
Ticket URL: <https://core.trac.wordpress.org/ticket/40136#comment:9>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list