Problem/Motivation

I have events which, for example, are on Daily from January 11th to January 15th inclusive, 10am to 4pm and I am struggling to get the output of this to work the way we hope. Ideally we would want to have Monday 11 January 2021 - Friday 15 January 2021 10am - 4pm. I have tried the Recurring smart date format however to get it to include the 15th the rule actually goes to the 16th and so the Rule which appears says "Daily at 10am until Saturday 16 January 2021" and when I output the time separately to get "10am to 4pm" it repeats for every instance.

Could someone point me in the right direction to alter the format of these? I am happy to code, just want to make sure I do it the right way but also make sure I just haven't missed something in the UI.

I am considering just having the date range Monday 11 January 2021 10am - Friday 15 January 2021 4pm for now but ideally we would be able to separate it out. Unless this is the way to do it?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tisteegz created an issue. See original summary.

mandclu’s picture

Interesting issue. Smart Date's standard formatter has separate handling for time and date ranges, so it sounds like what you want is to use both.

You would need to reduce the instances back to their rule, as is already done in the recurring formatter. Then you could determine your time and date ranges, and use the formatting functions which I believe reside in SmartDateTrait.

I like the idea of a compact way of listing daily events. Is there similar formatting we could do for weekly, monthly, and annual events? If so, maybe this could be a new formatter, or possibly even an option in the standard formatter.

MrPaulDriver’s picture

I had a very similar requirement for an event spanning 2 days and running between 10am and 5pm.

The best way I found for inclusion in a calendar was to create a daily event which ends after 2 repeats.

A downside to this approach when used with the recurring formatter, was a confusing repeat rule on the frontend, as quoted below.

Usually held Daily at 9:00am for 2 times

mandclu’s picture

Here's a first stab at a patch for this. Also including a couple of screen captures, to illustrate that the approach seems to work better with some formats than others.

mandclu’s picture

FileSize
5.2 KB

Updated patch to fix an an issue with the date vs time ordering

tisteegz’s picture

This seems to be working great for me! Will keep an eye out for the different date formats I add and make sure it works with them all.

MrPaulDriver’s picture

The patch works well for repeats with a defined end date. But it doesn't yet improve the rule display for dates which end after (number) of times.

Fortunately, the same treatment could applied.

Existing: Daily at 9:00am for 5 times

Becomes: Daily at 9.00am - Mon, Oct 5 - Fri, Oct 9 2020

Or perhaps better: Daily at 9.00am - Mon, Oct 5 - Fri, Oct 9 2020 (6 times)

Could a config option be provided for 'times' ? It's a bit nondescript - this would open the way for stuff like; sessions, occasions, sittings, lessons, performances, days, nights etc.

mandclu’s picture

Status: Needs review » Reviewed & tested by the community

@MrPaulDriver what you're suggesting sounds like a somewhat different request. Moving that discussion to #3174552: Option to configure label for "times" in Recurring formatter and marking this as RTBC based on previous feedback, but feel free to change it if additional work is needed on this new formatter.

MrPaulDriver’s picture

withdrawn. dupe

  • mandclu committed 2fc90c4 on 3.0.x
    Issue #3172866 by mandclu: Formatting of Recurring dates and time
    
mandclu’s picture

Status: Reviewed & tested by the community » Fixed

Merged in so closing this for now. Please create a child issue if there are additional ways this formatter could reduce duplication.

Status: Fixed » Closed (fixed)

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