- Issue created by @Chi
- Status changed to Needs work
over 1 year ago 2:30pm 10 February 2023 - last update
12 months ago 30,157 pass - Status changed to Needs review
9 months ago 6:23pm 13 December 2023 - 🇮🇳India arisen Goa
Good Suggestion. Will be an useful field formatter for date-range type fields.
Providing Functional tests for the formatter. - last update
9 months ago Custom Commands Failed - last update
9 months ago 30,724 pass - 🇮🇳India Nitin shrivastava
@arisen Can you please provide some steps on how to reproduce this issue..?
- 🇮🇳India arisen Goa
@Nitin shrivastava The issue summary has been updated.
Testing steps:- Setup a Drupal 11 site.
- Enable the Datetime Range module.
- Add Date Range field on any content type.
- Apply the provide patch.
- Go to the manage display tab of the content type and observe that a new Duration formatter is provided, select it and save.
- Add new content for the content type and view the content.
- The duration between start and end dates should be displayed instead of the actual dates.
- 🇮🇳India Sandeep_k New Delhi
Thanks for the Steps @arisen. Verified and tested patch duration_formatter-3340791-5.patch on Drupal version-
11.0-dev. The patch was applied successfully and looks good to me.Testing Steps:
- Set up the Drupal 11 site.
- I enabled the Datetime Range module.
- Added a Date Range field on any content type, Shared before results.
- Applied the provided patch.
- Go back to the Content>manage display tab> Go to Date formatter dropdown & select Duration and save.
- Add new content for the content type and view the content.
Testing Results:
Now instead of the Start & end date, the duration between the start and end dates is displayed instead of the actual dates. This can move to RTBC. - Status changed to RTBC
9 months ago 7:03am 15 December 2023 - Status changed to Needs review
9 months ago 7:25am 15 December 2023 - 🇮🇳India arisen Goa
Thanks @Sandeep_k for the review. This needs review from more community members so keeping it in needs review.
- Status changed to Needs work
9 months ago 2:46pm 15 December 2023 - 🇺🇸United States smustgrave
New formatter should have a change record. Visuals always help too.
- Status changed to Needs review
9 months ago 12:10pm 20 December 2023 - Status changed to Needs work
8 months ago 12:54am 2 January 2024 - 🇺🇸United States smustgrave
Think the formatter text needs some tweaking,
"Granularity" isn't super clear "How many different units to display in the range." doesn't help. This will need usability review probably got proper language.
But I change the granularity to 7 and it didn't have any impact on the display.
- 🇷🇴Romania claudiu.cristea Arad 🇷🇴
Wait, wait, wait… Shouldn’t this benefit from the Javascript functionality that we’ve already created in 🐛 Allow TimestampFormatter to show as a fully cacheable time difference with JS Fixed ?
IMHO, it’s the same thing, a time difference
- 🇷🇴Romania claudiu.cristea Arad 🇷🇴
Actually using that widget only makes sense when one of the range datetimes is NOW. But I have no idea if datetime range permits that
- 🇷🇺Russia Chi
if datetime range permits that
The field requires both dates to be specified statically.
- 🇷🇴Romania claudiu.cristea Arad 🇷🇴
@Chi, isn’t ✨ Allow end date to be optional Needs work an issue that will change this behavior?
- 🇷🇺Russia Chi
"Granularity" isn't super clear "How many different units to display in the range." doesn't help. This will need usability review probably got proper language.
That term is already used in "Time ago" formatter.
But I change the granularity to 7 and it didn't have any impact on the display.
The formatter output also depends on the range itself. If the difference between dates just a few seconds you will always see only one unit.
I think the more accurate label for this setting would be "Max granularity" but if we gonna use it same change needs to be applied to "Time ago" formatter.
- 🇷🇺Russia Chi
Re #20. Seems so. BTW D7 Date module also offered a way to get duration.
https://git.drupalcode.org/project/date/-/blob/7.x-2.x/date.module?ref_t... - 🇷🇺Russia Chi
The UI can be improved through formatter summary.
Have a look how it's done in "Time ago" formatter.
BTW, the time ago formatter limits the granularity to 6 by some reason.
- 🇷🇺Russia Chi
the time ago formatter limits the granularity to 6 by some reason
Created an issue. ✨ Increase max allowed granularity in Time ago formatter RTBC
- 🇮🇳India arisen Goa
The duration is not accurate enough when we use method formatInterval
Better to use method formatDiffTested with some sample data.
Instead of
$duration = $item->end_date->getTimestamp() - $item->start_date->getTimestamp(); $elements[$delta]['#markup'] = $this->dateFormatter->formatInterval($duration, $this->getSetting('granularity'));
need to use
$elements[$delta]['#markup'] = $this->dateFormatter->formatDiff($item->start_date->getTimestamp(), $item->end_date->getTimestamp(), ['granularity' => $this->getSetting('granularity')]);
- last update
8 months ago Build Successful - last update
8 months ago 25,960 pass, 1,793 fail - last update
8 months ago Patch Failed to Apply - last update
8 months ago Build Successful - Status changed to Needs review
7 months ago 7:38am 29 January 2024 - Status changed to Needs work
7 months ago 7:58pm 6 February 2024