This is a minor issue, but: I was looking for a way of showing only the start date and time of a date range, rather than both the start and end values. This module does exactly what I need when I use this date pattern in everything except the "all day" field:

l, F j, Y \a\t g:ia

Because time can (usefully) be included here, calling the formatter "Date range (without time)" doesn't really seem to make sense—maybe just "Date range"?

CommentFileSizeAuthor
#5 2947426-5.patch1.18 KBramya balasubramanian
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

noah created an issue. See original summary.

noah’s picture

Issue summary: View changes
pameeela’s picture

+1 to this, it is confusing because it works just fine with time.

ramya balasubramanian’s picture

Hi @noah, @pameela,

Date Range(without time formatter) is confusing , so for that I have changed the label and ID as 'Date Range'. Please let me know if anything needs to be changed.

config/schema/date_range_formatter.schema.yml
-field.formatter.settings.date_range_without_time:
+field.formatter.settings.date_range:
   type: field.formatter.settings.datetime_custom
-  label: 'Date range (without time)'
+  label: 'Date range'
src/Plugin/Field/FieldFormatter/DateRangeFormatterRangeFormatter.php
- *   id = "date_range_without_time",
- *   label = @Translation("Date range (without time)"),
+ *   id = "date_range",
+ *   label = @Translation("Date range"),
ramya balasubramanian’s picture

Status: Active » Needs review
StatusFileSize
new1.18 KB

As per above suggestions, I have uploaded the patch. Please have a look and let me know if there are any issues.

pameeela’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me.

sudishth’s picture

Status: Reviewed & tested by the community » Needs work

hi @ramya
we need to update the hook for the existing used field formatter config

darrick made their first commit to this issue’s fork.

darrick’s picture

Version: 8.x-3.x-dev » 9.0.x-dev
darrick’s picture

I would like to add support for examples like: "Wed 1 - 1:30PM Jun 9, 2022" instead of "Wed 1:00PM - 1:30PM Jun 9, 2022". I.e. setting to strip out minutes if 0 and setting to only show "meridiem" for end_value if equal to the start_value.

That would be like adding "Same AM/PM" and "Strip 00 times".

Before doing that I thought it would be better to swat this issue. Because maybe it is best to have one formatter for Date Only ranges and then inherit that formatter for a Date and Time formatter with the extra options for time.

From a user perspective I can see that "Date Range" make sense. But from a developer perspective I see that date_range_without_time makes sense as operationally no formatting decisions are being made based off the value of the time part only on the value of the date part.

  • sudishth committed 82e3cfd on 9.0.x
    Issue #2947426 by darrick, Ramya Balasubramanian, sudishth: Rename "Date...

  • sudishth committed 8808a9c on 9.0.x
    Issue #2947426 by darrick, Ramya Balasubramanian, sudishth: Rename "Date...
sudishth’s picture

Status: Needs work » Fixed

Thanks for patch

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

leo liao’s picture

ConfigManagerInterface::findConfigEntityDependentsAsEntities() is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Instead you should use ConfigManagerInterface::findConfigEntityDependenciesAsEntities(). See https://www.drupal.org/node/3225357