i have inheirited a php reservation system from another developer who didnt code properly for leap year, 2004. the php figures out how many days have passed and then matches that number with the day of the week to process the reservations. up until feb 29, 2003 it works fine, and then afterwards it is off by a day. i can see the problem with the code, but my coding is not good enough to be able to fix it... here it is...
function getDayofweek($month,$dayofmonth,$year){ //calculate days since 1.01.00 to determine day of week, mm,dd,yyyy
//takes leap years into account, but not century years after 2000
// January 1, 2000 was a Saturday
//for years beyond 2000, convert years to days
$add_day = 0;
$longdays = 0;
$year = (int)$year;
if($year!=2000){
$longdays = $year - 2000;
$longdays = $longdays*365;
while($year > 2000){
if($year%4==0)
$add_day++;
$year--;} //end while
} //end if
if($month=="January")
$daycount = 0;
else if($month=="February")
$daycount = 31;
else if($month=="March")
$daycount = 59;
else if($month=="April")
$daycount = 90;
else if($month=="May")
$daycount = 120;
else if($month=="June")
$daycount = 151;
else if($month=="July")
$daycount = 181;
else if($month=="August")
$daycount = 212;
else if($month=="September")
$daycount = 243;
else if($month=="October")
$daycount = 273;
else if($month=="November")
$daycount = 304;
else
$daycount = 334;
$daycount++; //add one day for leap year in 2000
$daycount = $daycount + $dayofmonth + $longdays + add_day; //add in days of current month
$dayofweek = $daycount%7;
return ($dayofweek);
}
function GetMonthnum($month){ //determine digit equivalent of month
if($month=="January")
$monthnum = "01";
else if($month=="February")
$monthnum = "02";
else if($month=="March")
$monthnum = "03";
else if($month=="April")
$monthnum = "04";
else if($month=="May")
$monthnum = "05";
else if($month=="June")
$monthnum = "06";
else if($month=="July")
$monthnum = "07";
else if($month=="August")
$monthnum = "08";
else if($month=="September")
$monthnum = "09";
else if($month=="October")
$monthnum = 10;
else if($month=="November")
$monthnum = 11;
else
$monthnum = 12;
return ($monthnum);
}
thanks in advance...