Months that start on a Sunday

Months that start on a Sunday

Postby ajwright » Wed Feb 13, 2008 4:21 pm

Hi,

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.
ajwright
 
Posts: 2
Joined: Wed Feb 13, 2008 4:17 pm

Re: Months that start on a Sunday

Postby ajwright » Wed Feb 13, 2008 4:51 pm

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>';
$j++;
}


It seems to fix the problem.
ajwright
 
Posts: 2
Joined: Wed Feb 13, 2008 4:17 pm

Re: Months that start on a Sunday

Postby chris » Thu Feb 14, 2008 1:16 am

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,
Chris
User avatar
chris
Site Admin
 
Posts: 1089
Joined: Mon Dec 17, 2007 7:42 pm
Location: Málaga, Spain


Return to General

Who is online

Users browsing this forum: No registered users and 2 guests

cron