Is there is an elegant way to disable moment.js's relative date formatting ("last week", "two days ago", etc.) particularly in the version history and workflow transition history of a content item?
When I inspect the version history of a content item, I see
<span class="pat-moment" data-pat-moment="format:relative;">17 days ago</span>
so presumably I could customize view templates so they don't use class pat-moment
... but that seems very heavy handed
I'm not sure about version history or workflow history, but here is what I did for the structure pattern (aka folder_contents): Showing dates in folder_contents in absolute format instead of relative
While we are 'at this subject': where should translations for pat moment be done ?
Interesting research I've had to go through
The folder contents pattern option "structure" with value {"momentFormat":"LLL"}
works because of this commit https://github.com/plone/mockup/commit/e942a8859512677c069776a471337834e488c71e Unfortunately it doesn't work for the @@historyview
I don't recognize an equivalent registry lookup for the moment pattern at https://github.com/plone/mockup/blob/master/mockup/patterns/moment/pattern.js though
line 126 https://github.com/plone/mockup/blob/master/mockup/patterns/moment/pattern.js#L126 uses self.options.format
Trying to use the resource registry to add a pattern called moment
with the value {"format":"LLL"}
doesn't have any effect.
I think format:relative
is hardcoded in the templates for plone.app.layout, in menu.pt
, content_history.pt
, and document_byline.pt
The good news is I can override those in my add-on, but it would be nice to have this format looked up in the registry... I am a bit leery of mucking with that though
the relative dates are a pest. structure pattern was fixed in 5.1 afaik, but at other places those are still active. pull requests to configure a consistent behavior are urgently welcome.
Thx Jens for egging me on to file this enhancement: add formatting or enable/disable option for moment.js relative datetimes · Issue #2254 · plone/Products.CMFPlone · GitHub which maybe should be a PLIP?
I dont think a PLIP is needed. This is just an enhancement of UX.