Skip to content
This repository was archived by the owner on Sep 24, 2018. It is now read-only.
This repository was archived by the owner on Sep 24, 2018. It is now read-only.

The date field of GET /comments should contain either a 'Z' time offset signature. #1675

Closed

Description

@southp

Environment

WordPress: 4.3.1
WP REST API: 2.0-beta 4
Machine: Chassis with VirtualBox 4.3.28 as its VM backend

How To

Using the following snippet:

#!/bin/sh
http POST <url> author_name='Shell' \
    author_email='shell@xd.cc' \
    author_url='http://goog.le' \
    content='wp rest api rocks!' \
    date='2015-10-22T12:00:00Z' \
    post=<pid> \
    parent=0

The date field of the response will be 2015-10-22T12:00:00, so does GET /comments.

According to the ECMAScript 2015 spec:

If the time zone offset is absent, the date-time is interpreted as a local time.

Thus, the returned date string is a local time string instead of the originally-submitted UTC time string for any browser implementing this spec.

Activity

  1. danielbachhuber commented on Oct 25, 2015

    @danielbachhuber
    Member

    Thanks for the detailed report.

    Dates are returned as ISO8601/RFC3339:

    'date' => mysql_to_rfc3339( $comment->comment_date ),
    'date_gmt' => mysql_to_rfc3339( $comment->comment_date_gmt ),

    The timezone is omitted because:

    Explicitly strips timezones, as datetimes are not saved with any timezone information. Including any information on the offset could be misleading.

    This decision was made in 6d0ad76. I'll flag this for discussion so we can reverify the decision.

    You can use the date_gmt value instead, but we'll need to expose it in the view context first. #1690

  2. added this to the 2.0 Beta 6 milestone on Oct 25, 2015
  3. southp commented on Nov 3, 2015

    @southp
    Author

    Hi @danielbachhuber ,
    Thanks for bringing it further. As long as there is no timezone information saved in the first place, I think it is still the right call to not including such an information. Exposing date_gmt value fits my purpose very well, as a plus it also disambiguates the purpose of date.

    Lastly, the document states the date as:

    The date the object was published.
    

    I think it might be clearer if we put it as something like:

    The date the object was published in the timezone as the blog settings.
    
  4. danielbachhuber commented on Nov 3, 2015

    @danielbachhuber
    Member

    I think it might be clearer if we put it as something like:

    Sounds good — submitted in #1715

  5. southp commented on Nov 4, 2015

    @southp
    Author

    Sounds good — submitted in #1715

    Thanks for the help. It looks even better 👍

  6. rmccue commented on Nov 9, 2015

    @rmccue
    Member

    According to the ECMAScript 2015 spec:

    Forgot to note, this is actually a recent change; previous specs have treated timezone-less strings as UTC time. Weird that the spec has broken backwards compatibility here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      Sponsor
      SponsoredKunjungi sekarang
      Promo