GenerateOccurrences Always Generates 1 Date


#1

Hi,

we have recently purchased a license for Aspose.iCalendar and have been testing out the functionality of GenerateOccurrences(). We have a dialog where the user specifies the RecurrencePattern for a series. On closing the form we validate the RecurrencePattern generated to ensure that at least one occurrence is generated by the pattern and, if it is not, our plan was to alter the pattern to change the EndType to Count and the Count to 1 so that 1 occurrence would be generated.

The problem we are encountering is that when the pattern specified should not generate any dates, GenerateOccurrences (called with no parameters) always returns one date - today’s date. Is this by design? If it is how would I go about detecting a pattern that should return 0 occurrences so that I can modify the pattern as described above?

Thanks in advance,

Graham


#2

According to the iCalendar standard (RFC2445) start date is considered the first occurrence date and always returned (unless explicitly excluded by EXDATE). I think this is what happens in your case - the start date of the pattern is always returned.

Although we comply to the standard, we think that always returning start date is the first occurrence is not good for some scenarious - for example for you.

This is not the first time we have this issue raised by our customers so we plan to address it. Probably, we will introduce an option to either comply with the standard and return start date as the date of the first occurrence or not.


#3

Thanks for the information.

Do you have any kind of timescale of when this option to comply with the standard or not will be built in?

In the meantime, I am going to perform a temporary kludge to get around the problem. I am going to set the pattern start date to a day before the actual start date should be and exclude that date from the pattern. Then, the actual start will only be generated as an occurrence if it falls within the range.

I think this should work as a temporary fix.

Thanks,

Graham


#4

Hi,

just to update anyone who’s interested in the workaround, in the case where the RecurrenceRule EndType is set to Count I have had to increment the Count by 1 to generate the dates that I expected (as the 1st occurrence counts as the StartDate which I am excluding).

Cheers,

Graham


#5

I am having the opposite problem - I can’t get the component to include the start date in the return from GenerateOccurrences(). My pattern is:

DTSTART:20040101T000000
RRULE:FREQ=DAILY;UNTIL=20040201T000000Z;INTERVAL=2
EXRULE:FREQ=DAILY;BYDAY=SA,SU

and the first date returned is 1/5/2004. I couldn’t really determine if the compenet was leaving the start date out or including it and what the proper behavior according to the RFC was. Any thoughts?


#6

The key to understand what happens in your example is that RRULE and EXRULE are processed identically and they both "include" the start date into the result set. Thus RRULE includes the start date and EXRULE excludes it.

We have some troubles understanding what behaviour is assumed by the standard in this case hence we left it as is for now, although I agree it does look odd.

To workaround and make sure start date is always included, add RDATE:20040101T000000 to your pattern. Vice versa, if you want to make sure the start date is always excluded, add EXDATE for it.

Please let me know if you have any strong thoughts or understand the standard on this issue well.


#7

The EXRULE specifies only Sat. and Sun., so I would not think that 1/1/2004, a Thursday, would be excluded based on that. Unless the point is that a rule, by definition, includes the start date, then I would (without referring to the RFC, btw) assume that rules would be processed in the order listed, meaning the behavior is correct. RDATE and EXDATE sound like excellent workarounds, though, as it would help clear up any ambiguity for other iCal implementaions that may handle the rules differently. Thanks!