[kronolith] daily recurrence calculation - sql driver

Jesse Wolff jesse_wolff@yahoo.com
Mon, 1 Oct 2001 16:50:09 -0700


Hi.

Attached is a patch to fix both of the issues I mentioned. They both occur in 
sql.php so they won't adversely affect mcal.

I tested it with a bunch of cases so recurrences should show up correctly now 
in all of the views no matter what the start time, except of course the 
Monthly:Same weekday recurrence which isn't yet implemented for the sql driver.

There's still an issue with the times for recurrences and multi-day events in 
the summary view but I'll send through another patch for that.

Jesse.

Index: lib/Driver/sql.php
===================================================================
RCS file: /repository/kronolith/lib/Driver/sql.php,v
retrieving revision 1.19
diff -r1.19 sql.php
128c128
<                     if ($next && Kronolith::compareDates($next, $endDate) <= 0
) {
---
>                     if ($next && Kronolith::compareDates($next, $endDate) < 0)
 {
230c230
<             $recur = (floor($diff->mday / $event->recurInterval)) * $event->re
curInterval;
---
>             $recur = (ceil($diff->mday / $event->recurInterval)) * $event->rec
urInterval;



Quoting Jesse Wolff <jesse_wolff@yahoo.com>:

> Hi.
> 
> I updated to the latest cvs tonight and noticed that recurrences are almost
> 
> complete for the sql driver!
> 
> There are two issues I ran into, one I know how to fix and the other I don't
> so 
> I'll just mention it.
> 
> 1) An event with a daily recurrence and a recur interval > 1 day doesn't show
> 
> up in the month view. The problem lead me to the daily recurrences
> calculation -
>  nextRecurrence() in sql.php, case KRONOLITH_RECUR_DAILY - and I'm pretty
> sure 
> it's not being done correctly.
> 
> To fix it, line 230 of sql.php should use the ceil() function instead of the
> 
> floor() function.
> 
> current: 
> $recur = (floor($diff->mday / $event->recurInterval)) *
> $event->recurInterval;
> 
> fix:
> $recur = (ceil($diff->mday / $event->recurInterval)) *
> $event->recurInterval;
> 
> The calculation with floor() correctly returns the next recurrence date only
> 
> when the passed date ($afterDate) is the next recurrence date which is why it
> 
> shows up correctly in the summary, day, and week views and not in the month
> 
> view unless the recur interval is 1 day. It fails in the month view for the
> 
> following reason:
> 
> If the event startdate is 10/2/2001 and the recurInterval is 2 (days), 
> month.php first calls nextRecurrence() passing it 10/3/2001. based on the
> above 
> calculation using floor(), $recur equals 0 when it should be 2.
> 
> I looked at a lot of examples and I'm pretty sure that the calculation using
> 
> ceil() correctly returns the next recurrence after the passed date
> ($afterDate).
> 
> After changing it, you can test it and it should show up correctly in all 
> views. BUT make sure your start time isn't equal to 12:00AM due to the next
> 
> issue.
> 
> 
> 2) Daily and weekly recurrences display properly (with the above change)
> except 
> when the event start time is 12AM. This is a problem whether you make the
> above 
> change or not.
> 
> To see this, create an event with a daily recurrence repeating every 3 or
> more 
> days and a start time of 12AM. You'll see in the summary, daily, and weekly
> 
> views that the event and it's recurrences also show up on the previous days.
> 
> The month view is fine.
> 
> So it's some kind of boundary issue with 12AM. I think nextRecurrence() is 
> incorrectly being called first with the previous day.
> 
> Thanks,
> Jesse 
> 
> -- 
> Kronolith mailing list: http://horde.org/kronolith/
> Frequently Asked Questions: http://horde.org/faq/
> To unsubscribe, mail: kronolith-unsubscribe@lists.horde.org
>