Details
-
Story
-
Resolution: Unresolved
-
High
-
None
-
None
-
None
Description
The various dates displayed by the UI would be more readable if they used a relative date and time format:
- "5 minutes ago"
- "a few seconds ago"
- "yesterday"
- "last year"
- "two years ago"
The real date must still be available when hovering on a date.
Benefits
We agreed in a discussion that relative dates are more practical in most cases, as long as the exact date is easy to get in addition (tooltip). It also helps leverage the topic of server vs client time, as a relative date will be valid independently of the timezone (reminder: dates are stored using the server's time).
Technical requirements
Back/Frontend
This should happen in every UI element, both server side and frontend generated elements. Without much data about this option, it sounds more logical to do this on the server side.
3rd party libraries or not ?
See open questions below. There are apparently libraries for this, even though their freshness should be verified first.
Examples/candidates:
- https://github.com/wookieb/relative-date
- https://github.com/KnpLabs/KnpTimeBundle
- http://momentjs.org (javascript)
PHP API
The code used to handle this should be re-usable, and maybe part of a Site API (e.g. public and maintained).
Twig support should be included.
REST API
The option of exposing this through the REST API as well should be considered. It would be fairly easy since we can add new elements, for instance by means of REST Field Type Processors.
Documentation
- Developer doc: this should be documented for those extending the UI, be it with FieldTypes or custom UIs.
- User doc: the screenshots that feature the date should be updated.
Open questions
To dev team
- Clarify if we would use a 3rd party library or custom code (both are fine, as it really depends on the available libraries and on what formats they support (see below).
- What exact formats do we want to support ? If we use a 3rd party library, we should stay close from what it supports. In any case, we need the exact answer to this question to complete the requirements. This may involve that dev has a look at the options, and define if it would be custom code or a 3rd party library.
To UI team
Should this be applied everywhere ? Or only to some/most dates ?