--- kronolith.orig/lib/Driver/kolab.php 2007-08-20 13:38:06.000000000 +0200 +++ kronolith/lib/Driver/kolab.php 2007-08-20 13:41:18.000000000 +0200 @@ -1084,10 +1084,25 @@ echo "Start: ".$startDate->compareDate($event->start)."
\n"; echo "End: ".$endDate->compareDate($event->end)."
\n"; */ - // check normal event date - if ($startDate->compareDate($event->start) <= 0 - && $endDate->compareDate($event->end) >= -1) - { + /* + * check if event period intersects with given period (startDate, endDate) + * + * Possible cases of intersection of period A and period B: + * + * |------Period A------| + * case1: |--B--| + * case2: |----B----| + * case3: |----B----| + * case4: |----B----| + * case5: |--B--| + * case6: |---------------B-------------| + * + * case 1 and 5 should return FALSE ==> no intersection + * case 2,3,4 and 6 should return TRUE ==> intersection + * + */ + if (!(($endDate->compareDateTime($event->start) < 0) || ($startDate->compareDateTime($event->end) > 0))) + { $keep_event = true; } @@ -1095,9 +1110,8 @@ if (!$keep_event && $event->recurs()) { $next = $event->recurrence->nextRecurrence($startDate); - if ($next !== false && !$event->recurrence->hasException($next->year, $next->month, $next->mday) - && $startDate->compareDate($next) <= 0 - && $endDate->compareDate($next) >= 0) + if ($next !== false && !$event->recurrence->hasException($next->year, $next->month, $next->mday) && + (!(($endDate->compareDateTime($event->start) < 0) || ($startDate->compareDateTime($event->end) > 0)))) { $keep_event = true; }