[wp-trac] [WordPress Trac] #41032: REST API: Date fields do not support ISO8601

WordPress Trac noreply at wordpress.org
Thu Mar 21 02:29:15 UTC 2019


#41032: REST API: Date fields do not support ISO8601
--------------------------------------+-----------------------------
 Reporter:  jnylen0                   |       Owner:  (none)
     Type:  defect (bug)              |      Status:  new
 Priority:  normal                    |   Milestone:  Future Release
Component:  REST API                  |     Version:
 Severity:  normal                    |  Resolution:
 Keywords:  has-unit-tests has-patch  |     Focuses:  docs, rest-api
--------------------------------------+-----------------------------
Changes (by nickylimjj):

 * keywords:  needs-unit-tests => has-unit-tests has-patch


Comment:

 Looks like I uploaded extra files because i used the `$ grunt
 upload_patch:41032`command. Will need to fix that...

 I modified the tests `test_rest_parse_date` and
 `test_rest_parse_date_force_utc`to `assertNotFalse` instead of
 `assertEquals` because I am getting different unix timestamps for
 `strtotime(...)` used in the `rest_parse_date` function in `wp-includes
 /rest-api.php` and the `gmmktime(...)` function for testing in
 `phpunit/tests/rest-api.php` For instance

  php > echo gmmktime( 0, 0, 0, 1, 16, 2017 );
  1484524800
  php > echo strtotime( '2017-01-16' );
  1484542800
  php > echo strtotime( '2017-01-16T' );
  1484550000

 are all valid strings and it is sufficient to just `assertTrue`.


 This also seems to respond to #38614

 Reference:
 ISO8601 validation [https://www.myintervals.com/blog/2009/05/20/iso-8601
 -date-validation-that-doesnt-suck/]
 regex tester for ISO8601 validation [https://www.regextester.com/97766]

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


More information about the wp-trac mailing list