I have the same problem (as smurray in #11; http://drupal.org/node/337952#comment-1155008), quoted below, and have had it for several rc versions now. I've created repeating events and then filter them by their repeating date field in Views with "now+31" to get the upcoming month's repeating events. But the date of the event that's shown is the date of the first iteration of the event rather than the date of the upcoming repetition. That's confusing for users, to whom it looks like the event is already past. I can and do add in the event's description that this is a repeating event (e.g. held the first Tuesday of each month), but ideally they would see the date of the next scheduled repetition in the node description, and that's not currently what's appearing. I'm not sure this is a bug per se, but might be a missing feature: show the date of the next upcoming repetition rather than that of the first iteration. I'd be grateful for clarification on that, too. :-)

Karen noted #337952 as fixed (comment #7), and the release notes for calendar 6.x-2.0-rc6 show this thread's fix was included in that release, but I still see my problem after updating. But the problem smurray and I are having is not the one originally described in this thread, so it should go in a new one.

#11 (http://drupal.org/node/337952#comment-1155008)
smurray - December 15, 2008 - 01:00
I partially solved the problem, but am still having issues. I discovered that if I delete my events and recreate them, the time and date are displayed in my upcoming events block. The problem is it's only showing the times for the first instance of the event. For example, when I recreated everything the upcoming events block was full of 5 events, all with time/dates. As the events past though and next weeks instance of the event shows up on the list, it isn't showing the time or date for it. The only way to get it to show up is to delete and recreate the event again. Obviously doing this each week for the 5 regularly repeating events would be a major pain in the butt. Anyone have any ideas?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ericm’s picture

No responses, eh? Not too many people using repeating events?

From what I can tell there are two possible solutions. One would be to implement some kind of Token system, e.g. "%upcoming-repeat" to insert the next date of the repeating event. That would be useful, but probably complicated.

The other approach would be to use the CCK system's Computed Field module and have a PHP snippet retrieve the nearest upcoming date for the repeating Event that CCK field is attached to. That would also be great for sorting CCK/Views lists to show a set of upcoming events in order.

Now if only I knew enough PHP and info about the Date system to write that code myself.... :-(

Eric

ericm’s picture

Project: Calendar » Date
Component: Code » Date Repeat API
Category: bug » support

I'm moving this thread out of the Calendar issues set to the Date project issues and making it a support request, under the Date Repeat API.
Eric

ericm’s picture

I'm guessing that I want to tap into date_repeat_calc($rrule, $start, $end) ["Analyze a RRULE and return dates that match it"] from "modules/date/date_repeat/date_repeat.module".

There's an example of using the Date module in a Computed Field here whose "Computed code" is shown below, for "Calculating a duration given a start and end time":

$start_date = date_make_date($node->field_start_time[0]['value']);
$start = $start_date->db->parts;
$end_date = date_make_date($node->field_end_time[0]['value']);
$end = $end_date->db->parts;
$start_decimal = $start['hours'] + ($start['minutes'] / 60);
$end_decimal = $end['hours'] + ($end['minutes'] / 60);
$node_field[0]['value'] = $end_decimal - $start_decimal;

Perhaps I want a snippet something like this, to take the first element in the array returned by date_repeat_calc() (assuming that $rrule is already defined somewhere, which it probably isn't):

$start = date_make_date('now');
$node_field[0]['value'] = date_repeat_calc($rrule, $start, $rrule['UNTIL'])[0];

Hopefully, that would give me a computed field for "the next date this event will happen." Anyone who knows this stuff have any details for me, please?

ericm’s picture

I'm poking around Karen's code trying to get ideas. Perhaps sometime more like...

// Note that my repeating event nodes have a datetime field named 'field_datetime_repeating'
$start = date_make_date('now');
$rrule = $node->field_datetime_repeating[0]['rrule'];
$node_field[0]['value'] = date_repeat_calc($rrule, $start, $rrule['UNTIL'])[0];

I also need a formatting snippet for "Display Format', perhaps something like:
$display = date_format_date($node_field_item['value'], 'custom', 'M j Y h:ia e');

ericm’s picture

Well, so far no good. The problem is that I don't know what formats date_repeat_calc($rrule, $start, $end, $exceptions) expects any of its arguments to be in, nor am I sure how to properly convert the data I am able to gather into the expected argument format. Depending on what I feed it date_repeat_calc() either returns the $start else returns the current time.

On the other hand, I think "Computed Field" is definitely the way to go, since it looks like it will answer "what is the next date this event happens?" so that I can display that as part of the node and also use it in Views for display and for sorting.

I need a break to ponder and let my head and the wall recover. Maybe in the meantime someone will have mercy on me and point me in a useful direction to code this.

Some pieces I've been ignorantly playing with in the "Computed Code" section are...

// Note that my repeating event nodes have a datetime field named 'field_datetime_repeating'
//require_once('./'. drupal_get_path('module', 'date_api') .'/date_api_ical.inc'); // needed for date_ical_parse_rrule()

// SET RRULE
//$rrule_text = $node->field_datetime_repeating[0]['rrule']; // This works! Retrieves a string with "RRULE:" prefix, like that below.
$rrule_text = 'RRULE:FREQ=MONTHLY;INTERVAL=1;BYDAY=4TU;UNTIL=20111025T040000Z;WKST=SU';
$rrule = $rrule_text;
//$rrule = date_ical_parse_rrule('RRULE:', $rrule_text); // returns an array of paired values
//$rrule = date_repeat_split_rrule($rrule_text); // returns an array {$rrule_pairs, $exceptions_list}
//$rrule = $rrule_text->db->parts;

// SET START AND END
//$start = date_make_date('2009-01-01 00:00:01');
//$end = date_make_date('2010-01-09 15:58:36');
$start = '2009-01-01 00:00:01';
$end = '2010-01-09 15:58:36';
//$start = '20090101T000001Z';
//$end = '20111025T040000Z';
//$start = date_make_date('now');
//$end = $rrule['UNTIL'];

$upcoming = date_repeat_calc($rrule, $start, $end);
$node_field[0]['value'] = $upcoming[0];

ericm’s picture

Some progress... the reason I was getting the event's start date was because the first value in the array of dates returned by date_repeat_calc() is always the $start date even if it doesn't match the RRULE (as per _date_repeat_calc() in date_repeat_calc.inc), so you need to take the second value in the array. This code gets somewhere:

// Note that my repeating event nodes have a datetime field named 'field_datetime_repeating'
// The following line needed for date_ical_parse_rrule()
require_once('./'. drupal_get_path('module', 'date_api') .'/date_api_ical.inc');
// The following line retrieves a string with "RRULE:" prefix associated with the node
$rrule = $node->field_datetime_repeating[0]['rrule'];
// I don't know how to retrieve the exceptions yet, so...
$exceptions = array();
// Our start date for the selection range is right now
$start = date_now();
// End date for the selection range should be the UNTIL of the RRULE
//$rrule_parsed = date_ical_parse_rrule('RRULE:', $rrule);
//$end = date_ical_date($rrule_parsed['UNTIL']);
// but since those two lines aren't working, I'm using this for now...
$end = '2010-01-01 00:03:03';
// Setting the timezone can be tricky, but this will do for now...
$timezone = date_default_timezone_name();
// Finally, retrieve the array of upcoming dates
$upcoming = date_repeat_calc($rrule, $start, $end, $exceptions, $timezone);
// and use the second value as the soonest upcoming date
$node_field[0]['value'] = $upcoming[1];

For the "Display Format" I'm using the very ugly:

$display = date_format_date(date_make_date($node_field_item['value']), 'custom', 'M j Y h:ia e');

although there must be a better way to do that.

What I get is the next upcoming date for the repeating event, BUT with the current time instead of the event's time! It's using the time from $start as the time for the next upcoming event. Yeesh. Perhaps I'll have to construct a composite datetime, using the date returned by date_repeat_calc() and the time from the event's actual start time. Or something.

Here's what the fields look like right now to the enduser viewing the node:

Location:
Amina 's home (please contact her for more information)
Contact:
Amina
Next upcoming event date:
Jan 27 2009 11:31pm America/Toronto
Date and time (date of first event, then repeats):
Oct 28 2008 8:30pm America/Toronto
Repeats every month fourth Tuesday until Tue Oct 25 2011

Note that I had to add "(date of first event, then repeats)" to the field "field_datetime_repeating" Label to make an attempt at not confusing the reader. (sigh)

As before, any insights or suggestions would be greatly appreciated.

ericm’s picture

Incidentally, I think mwbyrd in this thread is having the same problem that set me on this journey... the upcoming events block shows the date of the first event and not the upcoming iteration.

Note that could probably be fixed by having Views use the second item in the array returned by date_repeat_calc(), but I would still want to be able to show a field for "Next upcoming event date:" in the node for the event. So the journey continues...

ericm’s picture

Some good progress! I can now get the computed field to generate a correct "next upcoming event" datetime, and with correct time and timezone. I still need to test the exceptions mechanism, include some value checking, and adjust the output to use the local datetime format.

Here is the Computed Code:

// Note that my repeating event nodes have a datetime field named 'field_datetime_repeating'
// All processing should be done in UTC (the database's timezone), then converted to local timezone at the end

// The following line is needed for date_ical_parse_rrule() below.
require_once('./'. drupal_get_path('module', 'date_api') .'/date_api_ical.inc');

// GET THE DEFAULT TIMEZONE FOR THE USER IF SET ELSE SITE.
// If Views is going to use this value, I need to know what the right timezone should be (local or UTC). Use local for now.
$timezone = date_default_timezone_name();

// GET RRULE
// The following line retrieves a string value with "RRULE:" as prefix.
// e.g. "RRULE:FREQ=MONTHLY;INTERVAL=1;BYDAY=4TU;UNTIL=20111025T040000Z;WKST=SU"
$rrule = $node->field_datetime_repeating[0]['rrule'];

// SET START DATE
$start = date_now($timezone);

// SET END DATE AND EXCEPTIONS
// End date should be the UNTIL from the RRULE for this event.
$parts = date_repeat_split_rrule($rrule);
$rrule_array = $parts[0];
$exceptions = $parts[1];
$end = date_format_date(date_ical_date($rrule_array['UNTIL']), 'custom', 'Y-m-d H:i:s');
// TO DO: If there's no UNTIL found, set it to an arbitrary date of one year from now.

// FINALLY, GET THE UPCOMING DATES ARRAY AND TAKE THE FIRST UPCOMING DATE IF ANY.
$upcoming = date_repeat_calc($rrule, $start, $end, $exceptions, $timezone);
// The first item in the resulting array is always the $start (as per _date_repeat_calc() in date/date_repeat/date_repeat_calc.inc).
if (count($upcoming) < 2) {
// No upcoming dates.
$node_field[0]['value'] = "";
}
else {
// Retrieve the event's fromdate in the database's UTC timezone,
// adjust it to the local timezone,
// and prepare a version in datetime format
$fromdate_text = $node->field_datetime_repeating[0]['value'];
$fromdate = date_make_date($fromdate_text, 'UTC');
date_timezone_set($fromdate, timezone_open($timezone));
$fromdate_text = date_format_date($fromdate, 'custom', 'Y-m-d H:i:s');
// Set the upcoming event's time to the actual event's time, and pass on a DATE module date array
$fromdate_array = explode(" ", $fromdate_text);
$nextdate_array = explode(" ", $upcoming[1]);
$nextdatetime = $nextdate_array[0] . " " . $fromdate_array[1];
$node_field[0]['value'] = date_make_date($nextdatetime, $timezone);
}

Here is the Display Format:

if ($node_field_item['value'] == "") {
$display = "No upcoming repeats";
}
else {
// TO DO: Need to change this to use the correct local site date format
$display = date_format_date($node_field_item['value'], 'custom', 'M j Y h:ia e');
}

And here is the "fields" section from an example node:

Location:
Amina 's home (please contact her for more information)
Contact:
Amina
Next upcoming event date and time:
Jan 27 2009 08:30pm America/Toronto
Date and time (date of first event, then repeats):
Oct 28 2008 8:30pm America/Toronto
Repeats every month fourth Tuesday until Tue Oct 25 2011 except Tue Dec 23 2008, Tue Dec 22 2009

ericm’s picture

Well, I thought I had it. It works fine when I look at the node's page immediately after saving my new code. But subsequent views of the page generate this error (unless I again save a copy of my code):

warning: date_format() [function.date-format]: The DateTime object has not been correctly initialized by its constructor in /home/ageofi2/public_html/sites/all/modules/date/date_api.module on line 601.

A quick glance at the Web doesn't show me how to fix that. I need another break to ponder it. :-(

Line 601 is the last line (the 'return') of date_format_date():
return date_t(date_format($object, $format));

ericm’s picture

Alright , the problem was that I was generating a date object in the Computed Field section and passing that to the Display Format snippet. Using an object is a big no for that. I switched to using a datetime STR and it works fine now.

However, it turns out that if you want to sort by upcoming date in views, you need to store the value of the upcoming date in the database. That value is only written when the node is saved, not upon every view. There are some methods folks have devised for automating the Computed Fields updating, none of which seems ideal for me. I think I'd rather just use a cron process to load a page at 2am or something, that will automatically update all repeated event nodes or at least update their "next upcoming date" computed field. Another project. :-(

Also, when I tried to sort on upcoming date in Views I got a mess. It looked like the sort happened before the filter, which makes no sense. More news on that as I figure it out (if I do).

Anyway, here's the final code for Computed Fields to generate a field that shows the next upcoming date in node view, and makes it available (in non-updating fashion) to Views for display in Blocks (for instance).

Computed Code

//  Note that my repeating event nodes have a datetime field named 'field_datetime_repeating'
//  The following line is needed for date_ical_parse_rrule() below.
    require_once('./'. drupal_get_path('module', 'date_api') .'/date_api_ical.inc');
//  GET THE DEFAULT TIMEZONE FOR THE USER IF SET ELSE SITE.
//  If Views is going to use this value, I need to know what the right timezone should be (local or UTC). Use local for now.
    $timezone = date_default_timezone_name();
//  GET RRULE
//  The following line retrieves a string value with "RRULE:" as prefix.
// e.g. "RRULE:FREQ=MONTHLY;INTERVAL=1;BYDAY=4TU;UNTIL=20111025T040000Z;WKST=SU"
    $rrule = $node->field_datetime_repeating[0]['rrule'];
//  SET START DATE
    $start = date_now($timezone);
//  SET END DATE AND EXCEPTIONS
// End date should be the UNTIL from the RRULE for this event.
  $parts = date_repeat_split_rrule($rrule);
  $rrule_array = $parts[0];
  $exceptions = $parts[1];
  if ($rrule_array['UNTIL'] == "") {
// If there's no UNTIL found, set it to an arbitrary date of one year from now.
    $end = date_format_date(date_make_date(time() + 31622400, $timezone, DATE_UNIX), 'custom', 'Y-m-d H:i:s');
  } else {
    $end = date_format_date(date_ical_date($rrule_array['UNTIL']), 'custom', 'Y-m-d H:i:s');
  }
//  FINALLY, GET THE UPCOMING DATES ARRAY AND TAKE THE FIRST UPCOMING DATE IF ANY.
    $upcoming = date_repeat_calc($rrule, $start, $end, $exceptions, $timezone);
//  The first item in the resulting array is always the $start (as per _date_repeat_calc() in date/date_repeat/date_repeat_calc.inc).
    if (count($upcoming) < 2) {
//  No upcoming dates.
      $node_field[0]['value'] = "";
    } else {
//  Retrieve the event's fromdate in the database's UTC timezone, adjust it to the local timezone, and prepare a version in datetime format
      $fromdate_text = $node->field_datetime_repeating[0]['value'];
      $fromdate = date_make_date($fromdate_text, 'UTC');
      date_timezone_set($fromdate, timezone_open($timezone));
      $fromdate_text = date_format_date($fromdate, 'custom', 'Y-m-d H:i:s');
// Set the upcoming event's time to the actual event's time, and pass on a datetime STR.
      $fromdate_array = explode(" ", $fromdate_text);
      $nextdate_array = explode(" ", $upcoming[1]);
      $nextdatetime = $nextdate_array[0] . " " . $fromdate_array[1];
      $node_field[0]['value'] = $nextdatetime;
    }

Display Format

if ($node_field_item['value'] == "") {
   $display = "No upcoming repeats";
}
else {
    $display = date_format_date(date_make_date($node_field_item['value'], date_default_timezone_name()), 'small');
//    $display = date_format_date(date_make_date($node_field_item['value'], date_default_timezone_name()), 'custom', 'M j Y g:ia'); // custom format
}

Also, make sure to check "Store using the database settings below" if you need to use the computed field in Views. With that, also select "varchar" with a data length of 19, and mark "sortable."

Good luck!

ericm’s picture

An update on the updating issue...

If you don't need to use the Next Upcoming Event Date information in Views, don't check "Store using the database settings below" and the correct current value will be calculated and displayed correctly on every node view. If you do store the value in the datebase (because you require it to be available to Views) then it will not be updated unless you use/create some method of updating it.

I've found several ways to update the computed value, and which is correct depends on your needs.

  (1) Update the nodes manually. For each node with a Computed Value stored in the database, open the node for editing and just save it. Downside: must do that for every repeating event node, and it changes the last updated timestamp for the node.

  (2) Batch update the set of repeating events nodes manually. There are three ways:

    (a) Use the Views Bulk Operations module and create a view with your repeating event node type and "save post" action. Go to that view to do the bulk update. I haven't tried this yet, and my description is an outline of my current understanding of how it should work. This was suggested here.

    (b) Use a module that regenerates Computed Fields for the node types that you select. One for Drupal 5 is here and one for Drupal 6 is here. Note that two people on that thread reported it still didn't work for 6.8, and two said it did. I haven't tested this yet.

    (c) Create a page with embedded PHP code specifically for updating your repeating events nodes. This was addressed in an older thread, which might work if updated for Drupal 6. In particular, the table name convention has changed, so for my installation the right table name is "content_type_event_repeating" for retrieving nids. The newer thread has related code that could work too. I'll probably try something related to this, since I can call the Drupal page with the embedded code from cron to update the nodes.

Note that updating the timestamp when you save a node to update its computed fields is a problem if you have a Views block that displays recently updated pages/events (as I do), since you don't want the repeated event nodes to show up there just because you ran an operation to update the Next Upcoming Event Date value. The comment here addresses that issue.

Note also that if you have a lot of repeating event nodes the updating task might time out, and a method for doing it in batches would need to be implemented.

Finally, none of this will generate the current Next Upcoming Event Date on the fly for Views, which is what this person wants, and probably others too. This would take a modification to the Date module to have it automatically create a computed field of its own and update it upon a Views filter, sort, or fields request. Complicated.

ericm’s picture

I was reading the documentation for Views and I think it may be possible for Date to generate a pseudo-field that would present the Next Upcoming Date by calculating it rather than retrieving it from a stored value in the database. The Advanced Help documentation for the Views API (Home › Help › Views › Views' API > Describing fields on tables) says:

Aside from the special table tag, each table can also have an unlimited number of field designations; these correspond roughly to fields on the table, though it is very common to use non-fields to display data that isn't directly in a field, such as data arrived from formulae, or special links related to the object the table is part of.

So it should be possible for the Views form to show a Content:NextUpcomingDate field even without it being stored in the database, if the Date module has the proper hooks to generate a value for that field.
Unfortunately, I tried finding how one might do such a think in the Views documentation and my eyes caught fire. I thought using Views was a bit complicated, but the underlying code is crazy stuff and the documentation is written for wizards. Damn.

But I think a different approach might be best anyway. I think I've figured out a way to describe the original Date/Views problem in such a way that KarenS might recognize what I mean and maybe see an immediate solution. More news as it happens...

ericm’s picture

I updated the Computed Code from #10 a bit to make it more user-friendly, so that the header offers a place to set your own value for your installation's repeating datetime field name.

//  Note that my repeating event nodes have a datetime field named 'field_datetime_repeating' but you
//  should change the line below to your repeating event node's field name for this value. 
    $datetime_repeating = "field_datetime_repeating";
//  The following line is needed for date_ical_parse_rrule() below.
    require_once('./'. drupal_get_path('module', 'date_api') .'/date_api_ical.inc');
//  GET THE DEFAULT TIMEZONE FOR THE USER IF SET ELSE SITE.
//  If Views is going to use this value, I need to know what the right timezone should be (local or UTC). Use local for now.
    $timezone = date_default_timezone_name();
//  GET RRULE
//  The following line retrieves a string value with "RRULE:" as prefix.
// e.g. "RRULE:FREQ=MONTHLY;INTERVAL=1;BYDAY=4TU;UNTIL=20111025T040000Z;WKST=SU"
    $rrule = $node->{$datetime_repeating}[0]['rrule'];
//  SET START DATE
    $start = date_now($timezone);
//  SET END DATE AND EXCEPTIONS
// End date should be the UNTIL from the RRULE for this event.
  $parts = date_repeat_split_rrule($rrule);
  $rrule_array = $parts[0];
  $exceptions = $parts[1];
  if ($rrule_array['UNTIL'] == "") {
// If there's no UNTIL found, set it to an arbitrary date of one year from now.
    $end = date_format_date(date_make_date(time() + 31622400, $timezone, DATE_UNIX), 'custom', 'Y-m-d H:i:s');
  } else {
    $end = date_format_date(date_ical_date($rrule_array['UNTIL']), 'custom', 'Y-m-d H:i:s');
  }
//  FINALLY, GET THE UPCOMING DATES ARRAY AND TAKE THE FIRST UPCOMING DATE IF ANY.
    $upcoming = date_repeat_calc($rrule, $start, $end, $exceptions, $timezone);
//  The first item in the resulting array is always the $start (as per _date_repeat_calc() in date/date_repeat/date_repeat_calc.inc).
    if (count($upcoming) < 2) {
//  No upcoming dates.
      $node_field[0]['value'] = "";
    } else {
//  Retrieve the event's fromdate in the database's UTC timezone, adjust it to the local timezone, and prepare a version in datetime format
      $fromdate_text = $node->field_datetime_repeating[0]['value'];
      $fromdate = date_make_date($fromdate_text, 'UTC');
      date_timezone_set($fromdate, timezone_open($timezone));
      $fromdate_text = date_format_date($fromdate, 'custom', 'Y-m-d H:i:s');
// Set the upcoming event's time to the actual event's time, and pass on a datetime STR.
      $fromdate_array = explode(" ", $fromdate_text);
      $nextdate_array = explode(" ", $upcoming[1]);
      $nextdatetime = $nextdate_array[0] . " " . $fromdate_array[1];
      $node_field[0]['value'] = $nextdatetime;
    }
ericm’s picture

I found the problem in Date's Views operation on repeating dates! There will be no need to modify Date, store the Next Upcoming Date value in the database, or to create a method for updating that database value. It turned out the problem was trivial to fix, and basically the result of undocumented or just plain weird behavior.

If you create a View using a repeating datefield, and filter it to show the next X days of upcoming repeats using that datefield property, you need to adjust the filter's "Configure extra settings for filter Date: Date" page to use the AND method and not the OR method. If you use the OR method you get the correct set of events but the datetime shown for each event will be the datetime of the first iteration in the repeated event series. If you use the AND method then you get the same correct set of events but the datetime shown for each event will be the datetime for that particular iteration of the event. I'm going to try to describe this better in a separate issue posting.

As far as showing the Next Upcoming Event Date in the node view, you still need Computed Fields to generate that since the Date object shows the enduser-unfriendly field value of the original date plus the rule for repeats, plus the Repeats tab at the top of the node view. By using the Computed Field you get a proper Next Upcoming Event Date display. Also, since we aren't going to need to use that computed field in Views, we don't have to store the value in the database and the node view will calculate the correct view on the fly. Perfect! So ignore the last bit in #10 where I said you need to store the value if you're going to use it in Views. There's no need to use it in Views.

ericm’s picture

Assigned: Unassigned » ericm

The final version of the Computed Field code snippet set is now here (#357867), on a thread named more appropriately for the solution I ended up with.

I still need to write up the problem and solution (workaround?) for the repeating events Date+CCK problem described in comment #14.

robclay’s picture

Ericm - Wow! Thanks for the detailed analysis and sleuthing...

So #14 here suggests that this can be done without any modification to the current contributed modules?

Thanks for your work and sharing!

ericm’s picture

I've written up the problem and solution for the repeating events Date/CCK/Views problem described in comment #14 in a new issue #359878: repeating events show wrong dates.

jdschroeder’s picture

Thanks for the legwork on this ericm. This problem has been plaguing me as well.

dingbats’s picture

Eric this must have taken hours, thanks for digging into the code and finding a fix.

arlinsandbulte’s picture

Subscribing

This issue is bothering me as well.
Right now, I use Google Calendar on a site. It REALLY works well as a simple calendar system, but I want to better incorporate calendar, event, and announcement information into my Drupal site.

Thing is, I really don't want just a "Next upcoming event date and time."
What I want is the Date Field to actually show the date of the 'selected instance.' (Just like Google Calendar)
This way, I think it could better tie into this issue (http://drupal.org/node/298334) that is requesting the ability to modify the content of repeated instances as needed.

ericm’s picture

arlinsandbulte,

Yes, the computed "Next upcoming event date and time" shows (or should show) the actual next scheduled date even on future events. It's to some extent a workaround, although for the end-user it's not worthless to know what the next scheduled date of a repeating event is. I agree that it's not good to be forcing people to search through the "Repeats" tab to confirm the event is when the calendar says, just because the node display doesn't show the date of the actual instance.

The "ability to modify the content of repeated instances" is the Event modules specialty at this point, but I'm encouraged by (http://drupal.org/node/298334) to see that Karen thinks the ability to have Date (repeating) optionally create actual editable nodes might be worthwhile.

ericm’s picture

Just to make sure people don't get confused, the Computed Field code given above in this thread was my work in progress (i.e. buggy), but I've moved it into a new thread here (#357867: Computed Field calculates upcoming repeated event date), to emphasize that it is about showing the "Next upcoming date" and not a solution to the more complicated issue of having the node view show the actual date of that iteration, being discussed here (#298334: Repeating dates in separate nodes).

KarenS’s picture

There are several duplicates of this issue floating around. Repeating dates in separate nodes is a completely different feature request, not an attempt to fix this problem.

The value that should be displayed varies depending on where you are looking at the date, that's why it's not completely working yet. If you look at the date in the node, it should either show the first in the series or maybe the next in the series as mentioned in #21. But if you're looking at an individual repeating date in a view it should show the date you're looking at. And in the upcoming events list it should show the next occurence plus all subsequent occurences. And there are times, like in the repeats tab, where it should show all repeats. And to make it even more difficult, in most cases the theme does not know which of these things you are looking at. And on top of all that, you get come through themes depending on whether you are looking at the node or a view where you chose not to group multiple values or a view where you chose that you do want to group multiple values. So it's very hard to fix.

ericm’s picture

Yes, there seem to be several separate issues here. Also, they are indeed hard issues, in part because we're trying to understand our problems better. The duplication in threads in partly as a result of people perceiving their problem dimly, and not being sure which of the various implementation of solutions floating around in discussion would be suitable to fix their problem. At least that's my excuse. :-)

1. Node view currently doesn't make it easy to find the next date of a repeating event. (can be addressed with a Computed Field)
2. Views listings need to show the date of each particular iteration in the listing. (currently works great!)
3. Information associated with a particular iteration may need to be customized (e.g. who brings snacks). (could be addressed if Date optionally generated a set of (?semi-)independent nodes. (under discussion here: #298334: Repeating dates in separate nodes).
4. When people click on an event in a calendar display, the node view that comes up doesn't necessarily show any date corresponding to the date on the calendar that led them there, except buried in the Repeats tab. (would also be addressed by the generation of independent nodes, but for some people, including me, it may be an acceptable little bit of confusion in exchange for the administrative simplicity of a single rule-using node).

Ultimately, this may not be a problem to "fix" but rather a set of somewhat related issues that can be addressed through one or more of a set of optional solutions. If I can get the Computed Field working, then that's one tool in the kit (I'm using it as my excuse to learn PHP, so I apologize for its suckiness so far; feel free to step in!). If the option is available to have Date module generate a set of nodes vs. one rule-based repeating node then that's another (one that ends up looking a lot like Event module)

You're doing great. And I apologize for my rambly thinking out loud.

georgedamonkey’s picture

subscribing

KarenS’s picture

Status: Active » Fixed

I just committed a new feature to -dev that should take care of this and more. The formatters now have settings so you can do choose to show or not show the repeat rule, display all repeats or the first repeat or the next repeat from today or whatever. You can also choose if you want to display both the from and to dates, or just the 'From' date or just the 'To' date.

If you use Advanced Help you'll see some popup help for this. The formatter settings are on the Display fields page and when you add Date fields to views.

I'm sure it will still need some tweaking to produce the right results everywhere, but so far in my testing it works to make this all very customizable.

If there are no immediate bugs, I'm planning to roll a new release with this in it.

ericm’s picture

Assigned: ericm » Unassigned

I'm sure based on everything I've seen of your work that it will be a great solution. At least to the extent that it's possible to please all the people all the time. :-)

georgedamonkey’s picture

Sorry to bug you with this, I'm just very confused. I looked over the readme, and the advanced help and I'm not understanding what to do. Basically, for repeating events, I see this on a repeating event node:

Event Date and Time:
Repeats every week until Mon Mar 30 2009 .
February 9, 2009 6:30pm - 7:00pm
February 16, 2009 6:30pm - 7:00pm
February 23, 2009 6:30pm - 7:00pm
March 2, 2009 6:30pm - 7:00pm
March 9, 2009 6:30pm - 7:00pm
March 16, 2009 6:30pm - 7:00pm
March 23, 2009 6:30pm - 7:00pm
March 30, 2009 6:30pm - 7:00pm

Does this new update allow that display to change to be that particular day's event? Or, is that only for views?

ericm’s picture

georgedamonkey,

Right now your options for node display are to (1) show or hide the repeating date field, and (2) to show the complete list of repeats on the main node display or only the rule, with the complete list of repeats only tucked away in a "Repeats" tab. So either you (a) don't see the dates, (b) see the rule that generates the dates, or (c) see the rule plus the list of dates generated by the rule.

(1) You show/hide the repeat rule by hiding the date field, using "Admin > Content management > Content Types > Fields > {your repeating date field name} > {your repeating event node} > Display fields" or using "Admin > Content management > Content Types > {your event node type} > Manage fields > Display fields" and edit the form.
(2) You can have node display show or not show the complete list of dates in node display by using "Admin > Content management > Content Types > {your event node type} > Manage fields > {your repeating date field name} > Configure > Repeat display > expanded/collapsed" (it's way at the bottom).

My understanding of what Karen is saying is that the -dev version implements more flexibility in how (and what) information about the rule and/or resulting dates is shown for the field's value in whatever display it appears (node display or a Views-generated one). I haven't tried her -dev version yet, but instead of just a list of dates, a rule, or nothing, you will be able to show just the next upcoming date (for instance). I am eager (but will wait for it to be out of -dev before adding it to my production site!).

georgedamonkey’s picture

Oh, thank you so much! I saw the screen shots of showing so many values and what not but had no idea where you set that. Very nice. thank you again!

Status: Fixed » Closed (fixed)

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

kentr’s picture

This is still not working for me, I'm still getting duplicates.

Edit: I'm using Date 6.x-2.x-dev, downloaded 13:00 PST.

I have the Group settings as so (which is even more odd, because it's only showing one value under each):

Show 2 value(s)
starting from now
ending on now+1week

Included screenshots of preview and view display settings.

Another oddity, in case it's related, is that when I remove the Sorting argument, I only get about 10 items in the preview, not the 20 specified by the settings.

Peacog’s picture

I'm seeing the same problem using today's (July 27th) -dev version. The date of the first iteration is always shown. Can anyone confirm that this can be made to work? If so a step-by-step guide would be much appreciated, if you have the time. Thanks

scooper’s picture

Version: 6.x-2.0-rc6 » 6.x-2.3

I'm experiencing the same problem, using Date version 6.x-2.3. The date of the first iteration is always shown. This is confusing if you're only displaying one date (for example, with start date=now). What I think people are asking for is the first date listed to be that particular day's event. So for example, if you're displaying one date for the repeating event, and you click on the event from the calendar page for next month, ideally it would show that event's date, not the next event after "now" as it currently works.

I don't see this as a bug, but an enhancement to the options for the repeating dates display.

arlinsandbulte’s picture

Status: Active » Closed (fixed)

This issue is just too long with lots of different stuff.
A fix for the original issue has been committed.

KEEP this issue closed. If you need more, open a new issue.

aramalipoor’s picture

Hi guys,

for those of you who need to query for simple repeating dates (e.g. birthdays) you can use a tiny patch I've created for Views module that may help you. Note that this patch is for 7.x only.

It's Issue link is: #2014833: Change type of "Filter granularity" from radios to checkboxes to support views to query for repeating events