Iterator starts with the start date even if it doesn't fit the rule... is that right?

216 views
Skip to first unread message

gc1155

unread,
Jan 19, 2011, 7:59:34 PM1/19/11
to google-rfc-2445
Based on the code found in:
http://google-rfc-2445.googlecode.com/svn/trunk/README.html

I built a no-joda version and converted the example to use Java
Dates. The rule iterates through Friday the 13ths. If I limit the
count to 3 for brevity I get what I expect:

Fri Apr 13 23:49:25 CDT 2001
Fri Jul 13 23:49:25 CDT 2001
Fri Sep 13 23:49:25 CDT 2002

However, the example happens to set the start date to Friday, April
13th which matches the rule.

What should I expect if the start date is, say, right now? (which
definitely isn't Friday the 13th.)

The output is this:

Thu Jan 20 00:54:08 CST 2011
Fri May 13 00:54:08 CDT 2011
Fri Jan 13 00:54:08 CST 2012
Fri Apr 13 00:54:08 CDT 2012

Code:
// today
Date start = new Date();

// Every friday the thirteenth.
String ical = "RRULE:FREQ=MONTHLY"
+ ";BYDAY=FR" // every Friday
+ ";BYMONTHDAY=13" // that occurs on the 13th of
the month
+ ";COUNT=3"; // stop after 3 occurences

for (Date date: DateIteratorFactory.createDateIterable(ical, start,
TimeZone.getDefault(), true)){
System.out.println(date);
}


Mike Samuel

unread,
Jan 19, 2011, 8:09:39 PM1/19/11
to google-...@googlegroups.com
From 4.8.5.1 Exception Date/Times
The "DTSTART" property defines the first instance in the recurrence set...
The final recurrence set is generated by gathering all of the start
date-times generated by any of the specified "RRULE" and "RDATE"
properties, and then excluding any start date and times which fall
within the union of start date and times generated by any specified
"EXRULE" and "EXDATE" properties. This implies that start date and
times within exclusion related properties (i.e., "EXDATE" and
"EXRULE") take precedence over those specified by inclusion properties
(i.e., "RDATE" and "RRULE"). Where duplicate instances are generated
by the "RRULE" and "RDATE" properties, only one recurrence is
considered. Duplicate instances are ignored.

The "EXDATE" property can be used to exclude the value specified in
"DTSTART". However, in such cases the original "DTSTART" date MUST
still be maintained by the calendaring and scheduling system because
the original "DTSTART" value has inherent usage dependencies by other
properties such as the "RECURRENCE-ID".


From 4.8.5.3 Recurrence Date/Times
The "DTSTART" property defines the first instance in the recurrence set.


From 4.6.1 Event Component
The "DTSTART" property for a "VEVENT" specifies the inclusive start of
the event. For recurring events, it also specifies the very first
instance in the recurrence set.


2011/1/19 gc1155 <gc1...@gmail.com>:

> --
> You received this message because you are subscribed to the Google Groups "google-rfc-2445" group.
> To post to this group, send email to google-...@googlegroups.com.
> To unsubscribe from this group, send email to google-rfc-24...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-rfc-2445?hl=en.
>
>

gc1155

unread,
Jan 19, 2011, 9:27:24 PM1/19/11
to google-rfc-2445
Ahah. I suppose I should have read that. Thanks for the reply.

This works great. I noticed I had to be careful to zero out the
hours, minutes and seconds fields of the Date object passed to the
DateIteratorFactory.

String ical = "EXDATE;TZID=GMT:20110119\n" +
"RRULE:FREQ=MONTHLY;BYDAY=FR;BYMONTHDAY=13;COUNT=3";

Thanks

Mike Samuel

unread,
Jan 20, 2011, 1:12:09 AM1/20/11
to google-...@googlegroups.com
2011/1/19 gc1155 <gc1...@gmail.com>:

> Ahah. I suppose I should have read that. Thanks for the reply.
>
> This works great.   I noticed I had to be careful to zero out the
> hours, minutes and seconds fields of the Date object passed to the
> DateIteratorFactory.
>
>            String ical = "EXDATE;TZID=GMT:20110119\n" +
>                              "RRULE:FREQ=MONTHLY;BYDAY=FR;BYMONTHDAY=13;COUNT=3";
>
> Thanks

You're welcome.

Reply all
Reply to author
Forward
0 new messages