daily recurrence calculation - sql driver

Jesse Wolff jesse_wolff@yahoo.com
Mon, 1 Oct 2001 02:10:57 -0700


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