[wp-trac] [WordPress Trac] #28063: 'dayofweek' deviates from ISO-8601

WordPress Trac noreply at wordpress.org
Tue Apr 29 19:01:36 UTC 2014


#28063: 'dayofweek' deviates from ISO-8601
-------------------------+-----------------------------
 Reporter:  mboynes      |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Date/Time    |    Version:
 Severity:  normal       |   Keywords:
  Focuses:               |
-------------------------+-----------------------------
 In `WP_Date_Query`, specifying `'dayofweek'` uses MySQL's `DAYOFWEEK`
 function, which adheres to the ODBC standard where Sunday=1 and
 Saturday=7. There are two problems here:

 1. This deviates from the much-more-widely-accepted ISO-8601 standard,
 where Monday=1 and Sunday=7.
 2. PHP's `date()` function does not natively support this format, so it
 leaves it up to the developer to do the work. Since none of this is
 documented in the source or codex, it also means that developers have to
 figure it out for themselves. A developer might use `date()`'s `'N'` or
 `'w'` format, not even considering that WordPress uses yet a third format.

 I propose that we change this to use the ISO-8601 numeric representation
 of the day of the week.

 Of course, the most significant consideration in such a change is that
 this would be a "breaking" change. Queries using `'dayofweek'` would start
 returning results which were off by a day. I'm attaching a patch
 (dayofweek.diff) which makes this breaking change, if we want to go that
 route. Another possible route would be to deprecate `'dayofweek'` (but
 continue supporting it) and add `'weekday'`. This would allow Core to
 embrace the ISO standard without a breaking change. I'm attaching a
 separate patch (weekday.diff) which does this.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/28063>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list