The daterange field formatters will always render both the start and end dates for the range, but there's a use case for displaying only the start or the end date instead of both. Imagine creating an event listing view where you just want to display the start date/time for an event.

I propose modifying all three of the existing daterange field formatters and adding a configuration option to display both start and end (default), start only, or end only.

It's not much code, but because we have 3 formatters (plain, default (select from a pre-defined date format), and custom (enter in a custom format), the code needs to be repeated in all three. Perhaps there's a better way to refactor them so that's not the case.

Comments

bkosborne created an issue. See original summary.

mpdonadio’s picture

There is actually a decent amount of code now that is shared because of recent refactoring, and #2793143: The datetime and daterange formatters (except plain) should use the HTML time element is likely going to result in some more.

I am hesitant, though, to add options to these. The code change is mostly easy, but it starts to snowball when you add in the test coverage (tests for the three formatters times three for the the daterange flavors).

This is essentially a duplicate of #2827055: Add option to show only start or end date in the DateTime Range custom formatter, too. We can continue discussion there.

erik.erskine’s picture

The daterange_compact module could help with the use case you describe. It allows you to configure different patterns for the start & end date.

I don't see any reason why you couldn't set up a format with a blank pattern for the end date (or vice versa).