Problem/Motivation
There are several, potentially unintentional differences between the default formatter, and the custom formatter. When the default formatter was introduced, it went in using the HTML time element. RDFa support was introduced in #2139551: Support RDFa output in date formatter.
The custom formatter was introduced in #2399211: Support all options from views fields in DateTime formatters. The custom formatter doesn't use HTML time, nor does it have RDFa support, and from what I can tell, these are both oversights, rather than intentional.
The timeago formats also don't use the <time>
element, which preclude JS update callbacks to be attached to these to to allow dynamic updates to the loaded page (eg, update the time like Twitter does).
Proposed resolution
Use the time element for all formatted dates and date ranges. The plain formatter will continue to use basic markup. Aim for moving this code to common viewElements
on the base class(es).
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#11 | 2793143-11.patch | 2.97 KB | mpdonadio |
#3 | 2793143-03.patch | 4.17 KB | mpdonadio |
Comments
Comment #2
mpdonadioIn favor of this. In essence, the default formatters would use the defined date formats, and then the custom formatter would allow custom strings to be used on the fly. They are really two difference use cases that site builders need.
Do we want to scope this to also include the timeago formatters? That would be a stepping stone to JS enabling these for live updates, etc.
Comment #3
mpdonadioFirst pass; included timeago formatter. Didn't adjust any tests.
I think part of the question now is whether we want to refactor the tests a bit to combine some of the checking for this output now, since the same hunk is essentially used in about 10 places.
It also doesn't take into account some potential refactoring in our "#293" patch.
So, this is kind of a thought starter.
Comment #5
jhedstromThat makes sense to me (I haven't looked at how much work that is).
Comment #7
mpdonadioPostponing on the final version of #2775669: Clean up redundant methods in datetime field formatters.
Comment #8
mpdonadioUpdate IS to reflect proper scope and solve.
Comment #9
mpdonadio#2775669: Clean up redundant methods in datetime field formatters is in, but I think we may want #1918994: Improve Datetime and Daterange Widget accessibility in first?
Comment #10
mpdonadioAll of the blockers are in. Going to tackle this for my next big push, as when we do this, there is some additional refactoring that can fall out now that other work is in.
Comment #11
mpdonadioOk, bit it a restart b/c other work. Didn't adjust tests yet.
Two things.
What to do about DateTimeTimeAgoFormatter? We moved the viewElements onto the base class, but DateTimeTimeAgoFormatter doesn't extend it. Move these (back?) onto a trait?
DateTimeRangeTrait. Do we want to move these (back?) into the base class. But ^^^
Not sure how to proceed here.
Comment #13
jhedstromSeems like it was probably missed along the way. What happens if we remove the
viewElements
method and have it extend the base class?I'm not following the issue with
DateTimeRangeTrait
...Comment #14
mpdonadio#13, the timeago formatters don't inherit the base class b/c the settings are totally different; not much would really be inherited.
DateTimeRangeTrait. I think I need to diagram out these formatters to show the extends/implements/traits, with what we have now so we can see where we can go.
Comment #24
larowlanThis feels like a feature request so going to split the difference and make it a task
Comment #25
dwwSort of on the fence about bug vs. feature here. From the IS, it sounds like this was an unintentional oversight. If #2921810: Allow TimestampFormatter to show as a fully cacheable time difference with JS is a bug due to cache-ability concerns, maybe this should be, too? But sure, task sounds like a good compromise. 😉