Cyrus Daboo wrote:
> What this method does is expand the set of recurrences
from the very
> first one out to the supplied rangeEnd. So if the start
is greater
> than the end, then there will be no instances within
the range and no
> need to add the first one as determined by the 'start'
value.
>
[This is mostly for Bobby...]
We had a similar sort of epiphany in the chandler codebase -
There is a
general pattern for determining if an event appears in a
given week, or
month or whatever. As long as you can guarantee that for all
start/end
values, start<end, then the only real important checks
when checking if
an event occurs within a range is when the following is
true:
(eventStart <= rangeEnd && eventEnd >
rangeStart)
This covers all 4 cases of overlap between the event and the
range:
1) the event starts before the current range, but ends
within the range
2) the event starts before the range, and ends after the
range, thus
does appear in the range.
3) the event starts in the range, but ends after the range
4) the event both starts and ends within the range
There are some subtle difference when dealing with
recurrence instances
but I thought this was a useful enough tip/optimization
anyway...
Alec
> The overlap tests:
>
> (DTSTART <= start AND DTEND > start) OR
> (DTSTART <= start AND DTSTART+DURATION >
start) OR
> (DTSTART >= start AND DTSTART < end) OR
> (DTEND > start AND DTEND <= end)
>
> are not done exactly like that. What happens is that a
set of Instance
> objects is generated for each recurrence instance. The
Instance object
> has its own start/end associated with it, so all we
need to do is see
> whether those overlap the required range. That test is
done somewhere
> else.
>
_______________________________________________
Cosmo mailing list
Cosmo osafoundation.org
http://lists.osafoundation.org/mailman/listinfo/cosmo
|