Page 1 of 1

Months that start on a Sunday

PostPosted: Wed Feb 13, 2008 4:21 pm
by ajwright

I have been looking at your code with a view to using it as it does look good, but I have noticed that months that start on a Sunday do not display correctly, they start on a Monday instead. To see this, check out the availability calendar on your site for June 2008 and compare it to May 2008. May 2008 ends on a Saturday and June 2008 starts on a Monday according to the calendar.

I thought I'd let you know.

Re: Months that start on a Sunday

PostPosted: Wed Feb 13, 2008 4:51 pm
by ajwright
I had a look at this, and if you put the following code in:

Code: Select all
if ($first_week_day == 0)
$first_week_day =7;

Just before the point where it says:

Code: Select all
for($week_day = 0; $week_day < ($first_week_day-1); $week_day++)
$the_cal.='<td class="cal_empty">'.$cal_no_day.'</td>';

It seems to fix the problem.

Re: Months that start on a Sunday

PostPosted: Thu Feb 14, 2008 1:16 am
by chris
Hi and welcome to the forum :)

Thanks for pointing that one out and for giving me the fix ;)

I must admit that I haven't really concentrated on the actual php code to create the calendar for this script. My intention was more to make a demo ajax script.
That said there is no excuse for doing it badly so it is good to iron out these errors.

I have updated my demo and the zip file with your fix.

One improvement I want to make with this script is to make it possible to define the start day via a variable (shouldn't be too hard)

Thanks again,