[wp-trac] [WordPress Trac] #38342: Quick Draft: Leverage REST API endpoints

WordPress Trac noreply at wordpress.org
Sat Nov 19 22:43:57 UTC 2016


#38342: Quick Draft: Leverage REST API endpoints
---------------------------------+-----------------------------------
 Reporter:  adamsilverstein      |       Owner:
     Type:  enhancement          |      Status:  new
 Priority:  normal               |   Milestone:  Future Release
Component:  Administration       |     Version:
 Severity:  normal               |  Resolution:
 Keywords:  has-patch 4.8-early  |     Focuses:  javascript, rest-api
---------------------------------+-----------------------------------

Comment (by jnylen0):

 The latest file uploaded here ([attachment:38531.8.diff]) is from a
 different ticket (#38531).

 More generally, can we please fix this from earlier in the thread that
 hasn't been addressed yet?

 > If a post is created via the REST API without a date explicitly set,
 both `date_gmt` and `modified_gmt` will be null (`0000-00-00 00:00:00` in
 the database). This inconsistency forces us to use date instead, which is
 offset by the site's timezone setting. Working with dates -- particularly
 those with timezone offsets -- in JavaScript, is very difficult and error-
 prone. A library like Moment.js is almost essential if this is to become
 more common. Otherwise, it would be nice if we could be guaranteed that
 the REST API would return valid `_gmt` dates in all cases.

 If we can't fix the GMT issue and provide some clear recommendations for
 how to handle dates, certain edge cases around DST transitions are
 impossible to solve correctly, and we are strongly encouraging people to
 write broken code.  Using GMT dates is the best practice for a reason:
 handling dates/times correctly is really really hard, and that makes it
 much simpler.

 Also, it's fine to say "Date & time formatting is not handled in the API"
 ([https://github.com/WP-API/docs-v2/pull/190 ref]) - I agree that this
 should be handled by the client.  However, we should provide examples /
 functions / best practices for doing this.  Otherwise we will end up with
 WP installs containing 8 different date libraries, several copies of
 moment.js, hand-rolled date code that only works on the site where it was
 originally written (until DST comes around), and so on.

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


More information about the wp-trac mailing list