Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project!

## #152 Recur with WEEKLY frequency and INTERVAL>1 ignores BYDAY

open
Ben Fortuna
5
2012-06-24
2012-06-24
Ryan Trinkle
No

It seems that there's an issue with WEEKLY recurrences with INTERVALs over 1, where the seed date is (effectively) used as the WKST day instead of the actual WKST day being used. For example, with WKST=SU, if you have a semiweekly tuesday/thursday event, and the first occurrence is a thursday, the second occurrence should be 12 days later, not 5. There is an example in the iCalendar specification that makes this clear (see http://www.kanzaki.com/docs/ical/rrule.html\):

Every other week on Monday, Wednesday and Friday until December 24,
1997, but starting on Tuesday, September 2, 1997:

DTSTART;TZID=US-Eastern:19970902T090000
RRULE:FREQ=WEEKLY;INTERVAL=2;UNTIL=19971224T000000Z;WKST=SU;
BYDAY=MO,WE,FR
==> (1997 9:00 AM EDT)September 2,3,5,15,17,19,29;October
1,3,13,15,17
(1997 9:00 AM EST)October 27,29,31;November 10,12,14,24,26,28;
December 8,10,12,22

Here is some sample code (in Groovy):

import net.fortuna.ical4j.model.*
import net.fortuna.ical4j.model.parameter.*
seed = new DateTime("19970902T090000")
until = new DateTime("19971224T000000Z")
r = new Recur("FREQ=WEEKLY;INTERVAL=2;UNTIL=19971224T000000Z;WKST=SU;BYDAY=MO,WE,FR")
r.getDates(seed, seed, until, Value.DATE_TIME)

The last line returns the following, which differs from the results given in the iCalendar spec:

19970903T090000,19970905T090000,19970908T090000,19970917T090000,19970919T090000,19970922T090000,19971001T090000,19971003T090000,19971006T090000,19971015T090000,19971017T090000,19971020T090000,19971029T090000,19971031T090000,19971103T090000,19971112T090000,19971114T090000,19971117T090000,19971126T090000,19971128T090000,19971201T090000,19971210T090000,19971212T090000,19971215T090000

You can see that the third element of this result is September 8th, 1997; whereas, the 3rd result (excluding the initial occurrence, which is not part of the rrule) of the iCalendar spec's example is September 15th, 1997.