<div>I encountered a bug when generating recurring events when the rrule specifies BYDAY but the start of the event pattern is before the first day in the BYDAY list.</div>
<div> </div>
<div>For example:</div>
<div> </div>
<div>With rrule FREQ=WEEKLY;INTERVAL=1;BYDAY=MO,WE,FR;WKST=SU, but the start of the event pattern is on Sunday. The behavior I've noticed is that the call to "icalrecur_iterator_next" generates an event on Wednesday, with Monday being skipped.</div>
<div> </div>
<div>The attached and inline patch fixes this behavior.</div>
<div> </div>
<div>--Josh</div>
<div> </div>
<div>Index: libical/src/libical/icalrecur.c<br>===================================================================<br>RCS file: /cvsroot/freeassociation/libical/src/libical/icalrecur.c,v<br>retrieving revision 1.71<br>diff -u -8 -p -r1.71 icalrecur.c<br>
--- libical/src/libical/icalrecur.c 3 Feb 2008 16:10:46 -0000 1.71<br>+++ libical/src/libical/icalrecur.c 7 Apr 2008 23:02:12 -0000<br>@@ -944,19 +944,24 @@ icalrecur_iterator* icalrecur_iterator_n<br> days ahead ) will skip over some occurrences in the<br>
second week. */</div>
<div> /* This depends on impl->by_ptrs[BY_DAY] being correctly sorted by<br> * day. This should probably be abstracted to make such assumption<br> * more explicit. */<br> short dow = (short)(impl->by_ptrs[BY_DAY][0]-icaltime_day_of_week(impl->last));</div>
<div>- if (dow > impl->rule.week_start-1) dow -= 7;<br>- impl->last.day += dow;<br>- impl->last = icaltime_normalize(impl->last);<br>+<br>+ if((icaltime_day_of_week(impl->last) < impl->by_ptrs[BY_DAY][0] && dow >= 0) || dow < 0)<br>
+ {<br>+ /* initial time is after first day of BY_DAY data */<br>+<br>+ impl->last.day += dow;<br>+ impl->last = icaltime_normalize(impl->last);<br>+ }<br> }</div>
<div><br> }</div>
<div> /* For YEARLY rule, begin by setting up the year days array . The<br> YEARLY rules work by expanding one year at a time. */<br></div>