I'm using the date module for an event calendar and some of the events we schedule repeat, but they do not repeat on a regular interval. For instance, one event occurs three times on June 6, June 27, and July 25. There is no RRULE that adequately represents that sequence of repeats without having to create a large set of exceptions.

It's possible to create an arbitrary interval and then add additions to it or create a less arbitrary interval (every Wednesday until July 27) with a long list of exceptions, but it's not possible in the current module to just say, "Repeat on these three dates". Right now the Date module is rolling up RDATE into the RRULE variable and there is no way to add an RDATE without also adding an RRULE. So when I use either of the two above options for this event, I get a really unfriendly translation of the RRULE showing up on my event page.

"Beginning on June 6 occurs every Wednesday through July 25, 2012, except June 13, June 20, July 4, July 11 and July 18, 2012"
or
"Beginning on June 6 occurs every day through June 6, 2012 and also on June 27 and July 25."

Those options are ugly but they at least work. I have another event we're scheduling that doesn't really follow any pattern at all (not even the same weekday).

The iCalendar standard allows the definition of an event with an RDATE and no RRULE, but the Date module does not appear to support that (if I'm wrong, and it does, please point it out to me). I've already spent a lot of time writing a new version of date_repeat_rrule_description() to clean up the formatting of the human-readable rrule (which is why the above strings may look unfamiliar. After June 6 the "Beginning on June 6" part is no longer prepended to the string and it just starts with "Occurs..."). The way RDATE is currently implemented is so tightly integrated with the RRULE (in forms, rule parsing, date generation, etc.) that it's a pretty large undertaking to accommodate arbitrary repeating events.

What I'd like to be able to do is create a list of additional dates without selecting a repeat frequency and get an output result that looks something like, "Occurs June 6, 2012, June 27, 2012 and July 25, 2012."

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gotheric’s picture

Same problem for me...

gotheric’s picture

Status: Active » Needs review
FileSize
7.23 KB

I made a patch to support this.

In date editing it adds a new option to frequency dropdown: "None (only included dates)". If the user select this, frequency options and exclusions are hidden, and only "Include dates" is shown.

I commented all codes changes with "RDATE ONLY SUPPORT" text, to identify them better. Changes are quite simple.
An improvement could be to enable this code only if a global (or field) parameter is set.

I tested this code only on simple node editing and viewing and it works well, but maybe there are some different situations where it could have problems, don't know.

The patch is based on latest stable version (7.x-2.6)

Status: Needs review » Needs work

The last submitted patch, date_repeat_rdate_only_support.patch, failed testing.

mcrittenden’s picture

Here it is re-rolled for the latest 7.x-2.x with a couple small enhancements (such as auto-checking "Add addition" and hiding that checkbox since we know we want it to be checked if we chose to use arbitrary dates).

Screenshot: https://www.dropbox.com/s/s8hdkluc8eg9eey/Screenshot%202014-12-19%2001.2...

mcrittenden’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 4: date-1599016-3-arbitrary-repeat-dates.patch, failed testing.

mcrittenden’s picture

Version: 7.x-2.5 » 7.x-2.x-dev
Status: Needs work » Needs review
mcrittenden’s picture

And re-rolled again for version 2.8 (since that's the version I actually need in my make file at the moment).

Leaving ticket on version 2.x-dev since that's the patch that testbot needs to test (#4).

vijaycs85’s picture

Status: Needs review » Needs work

Thanks for your work. here are some review comments:

  1. +++ b/date_api/date_api_ical.inc
    @@ -699,8 +699,10 @@ function date_api_ical_build_rrule($form_values) {
    +    $RRULE .= 'RRULE:FREQ=' . (!array_key_exists('FREQ', $form_values) ? 'DAILY' : $form_values['FREQ']);
    

    this condition never met and we won't have 'DAILY' never ever!

  2. +++ b/date_repeat/date_repeat_calc.inc
    @@ -46,7 +46,7 @@ function _date_repeat_calc($rrule, $start, $end, $exceptions, $timezone, $additi
    +  if (empty($additions) && $rrule['FREQ'] == 'NONE' || (isset($rrule['INTERVAL']) && $rrule['INTERVAL'] == 0)) {
    

    can we add a comment saying why $additions necessary here?

  3. +++ b/date_repeat_field/date_repeat_field.module
    @@ -460,7 +460,7 @@ function date_repeat_build_dates($rrule = NULL, $rrule_values = NULL, $field, $i
    +    $end_datetime = $start_datetime;
    

    Not sure, it would work for all cases - Assuming end date == start date, if no 'show repeat settings'?

mglaman’s picture

+++ b/date_repeat/date_repeat_form.inc
@@ -646,6 +646,9 @@ function _date_repeat_rrule_process($element, &$form_state, $form) {
+      'checked' => array(
+        ":input[name=\"{$element['#name']}[FREQ]\"]" => array('value' => 'NONE'),
+      )

This breaks "Include Dates" unless choosing "NONE". Needs to be removed so existing functionality works as expected.

mglaman’s picture

Issue summary: View changes
Status: Needs work » Needs review
FileSize
93.19 KB
614 bytes
5.42 KB

this condition never met and we won't have 'DAILY' never ever!

It does catch

can we add a comment saying why $additions necessary here?

Not sure if we need to add a comment? It's just that additions can now be added without a specific repeat pattern.

Chris Matthews’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll, +Needs rework

The 4 year old patch in #12 does not apply to the latest 7.x-2.x-dev and may be too old to reroll, but I went ahead and tagged the issue accordingly.

Checking patch date_repeat_field/date_repeat_field.module...
error: while searching for:
  $rrule_values = date_repeat_merge($input['rrule'], $element['rrule']);

  // If no repeat information was set, treat this as a normal, non-repeating value.
  if ($rrule_values['FREQ'] == 'NONE' || empty($input['show_repeat_settings'])) {
    $item['rrule'] = NULL;
    form_set_value($element, $item, $form_state);
    return;

error: patch failed: date_repeat_field/date_repeat_field.module:336
error: date_repeat_field/date_repeat_field.module: patch does not apply