[wp-trac] [WordPress Trac] #39222: Add JavaScript date helpers
WordPress Trac
noreply at wordpress.org
Tue Mar 7 04:16:46 UTC 2017
#39222: Add JavaScript date helpers
---------------------------------------------------+-----------------------
Reporter: rmccue | Owner: rmccue
Type: feature request | Status: assigned
Priority: normal | Milestone: 4.8
Component: Date/Time | Version: 4.7
Severity: normal | Resolution:
Keywords: has-patch needs-unit-tests needs-docs | Focuses: rest-api
---------------------------------------------------+-----------------------
Changes (by rmccue):
* keywords: needs-patch => has-patch needs-unit-tests needs-docs
Comment:
[attachment:39222.diff] adds `wp-date.js` (and `wp.date.*`), which relies
on moment.js (also included). It also removes the Ajax endpoints used for
previewing formatted date/times, and replaces it with live JS instead:
[[Image(http://i.imgur.com/Ht202ww.gif)]]
This removes two admin-ajax.php endpoints (`date_format` and
`time_format`), and moves them to `wp-admin/includes/deprecated.php`.
It introduces new functions you can use:
* `wp.date.format()` - Format a date.
* `wp.date.date()` - Format a date in the site's timezone.
* `wp.date.gmdate()` - Format a date in UTC.
* `wp.date.date_i18n()` - Format a date, and translate it.
There are some pieces missing from the date translations:
* Ordinals aren't translated - this matches core, see #22225
* There's no equivalent of `human_time_diff()` - This requires full i18n
support (for plurals), and hence needs #20491 first.
Otherwise, should be basically complete feature-wise. This should probably
have unit tests.
This needs docs once we merge it; I'm not sure if our JSDocs are parsed
out anywhere right now, so in lieu of that, regular pages somewhere would
be great.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/39222#comment:11>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list