[wp-trac] [WordPress Trac] #51945: Dates in REST API responses are incompatible with date-time JSON schema format

WordPress Trac noreply at wordpress.org
Mon Dec 7 13:14:31 UTC 2020


#51945: Dates in REST API responses are incompatible with date-time JSON schema
format
--------------------------+------------------------------
 Reporter:  johnbillion   |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Date/Time     |     Version:  4.7
 Severity:  normal        |  Resolution:
 Keywords:  2nd-opinion   |     Focuses:  rest-api
--------------------------+------------------------------

Comment (by Rarst):

 I hadn't looked at the REST API specifically, but I brushed with related
 functions it introduced. Which led to some suboptimal discoveries and
 inline documentation updates.

 To my understanding REST API upholds that de facto time zone of the post
 is ''unknowable''. The local time of posts is in site's time zone ''at the
 time the post was made'' and there is no way to know if that is consistent
 with current setting. WP core just assumes that it is, so whenever
 timezone setting is changes, the local times on all existing posts are
 broken.

 On implementation level it does declare RFC 3339, however with a
 completely invalid assumption that it allows to omit time zone. It
 absolutely does not.

 Realistically the field as implemented cannot be changed, since change in
 format is a massive BC break for any consumer who expects a specific
 format. And in practice consumers are coded against implementation rather
 than specification (or they just wouldn't work).

 There might be a merit in introducing a ''new'' field with real RFC 3339
 time, but as above the ambiguity of time zone is a problem. I think time
 zone information was added somewhere as a global context, but that is
 technically different from codifying it as certain and valid for
 individual posts (which it isn't).

 I pondered in the past deriving time zone offsets for posts from GMT field
 (which is independent of setting), however that field isn't always filled
 and there is some amount of bizarre logic in core that couples its
 presence or absence to behavior (around drafts and stuff if I remember
 right).

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/51945#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list