day = date("d"); $this->month = date("n"); $this->year = date("Y"); } else { $this->day = $day; $this->month = $month; $this->year = $year; } $this->link = $link; } function isLeapYear($year) { if($year % 4 != 0) return false; //{use 28 for days in February} else if($year % 400 == 0) return true; //{use 29 for days in February} else if($year % 100 == 0) return false; //{use 28 for days in February} else return true; //{use 29 for days in February} } function buildMiniCalendar($height, $width, $selectedDayColor = "orange", $bgColor = "#eeeeee", $headerColor = "#0080ff") { $pmonth = $this->month == 1 ? 12 : $this->month - 1; $nmonth = $this->month == 12 ? 1 : $this->month + 1; $pyear = $pmonth == 12 ? $this->year - 1 : $this->year; $nyear = $nmonth == 1 ? $this->year + 1 : $this->year; if($this->day == 31) { switch($nmonth) { case 4: case 6: case 9: case 11: $nday = 30; break; case 2: $nday = $this->isLeapYear($nyear) ? 29 : 28; break; default: $nday = 31; break; } switch($pmonth) { case 4: case 6: case 9: case 11: $pday = 30; break; case 2: $pday = $this->isLeapYear($pyear) ? 29 : 28; break; default: $pday = 31; break; } } else if($this->day == 30) { switch($nmonth) { case 2: $nday = $this->isLeapYear($nyear) ? 29 : 28; break; default: $nday = 30; break; } switch($pmonth) { case 2: $pday = $this->isLeapYear($pyear) ? 29 : 28; break; default: $pday = 30; break; } } else if($this->day == 29) { switch($nmonth) { case 2: $nday = $this->isLeapYear($nyear) ? 29 : 28; break; default: $nday = 29; break; } switch($pmonth) { case 2: $pday = $this->isLeapYear($pyear) ? 29 : 28; break; default: $pday = 29; break; } } else { $pday = $this->day; $nday = $this->day; } switch($this->month) { case 4: case 6: case 9: case 11: $totalDaysInThisMonth = 30; break; case 2: $totalDaysInThisMonth = $this->isLeapYear ? 29 : 28; break; default: $totalDaysInThisMonth = 31; break; } $currenttime = mktime(0,0,0,$this->month, $this->day, $this->year); $output = ""; $output .= "
".date("M Y",$currenttime)."
"; $output .= ""; $output .= ""; if(date("w",mktime(0,0,0,$this->month, 1, $this->year))) { for($i=0;$imonth, 1, $this->year));$i++) $output .= ""; } for($i=1;$i<=$totalDaysInThisMonth;$i++) { if($this->day == $i && $this->month == date("n") && $this->year == date("Y")) $output .= ""; if((date("w",mktime(0,0,0,$this->month, $i, $this->year)) % 6 == 0) && (date("w",mktime(0,0,0,$this->month, $i, $this->year)) != 0) && $i != $totalDaysInThisMonth) { $output .= ""; } } if(date("w",mktime(0,0,0,$this->month, $totalDaysInThisMonth, $this->year)) != 0) { for($i=0;$i<6 - date("w",mktime(0,0,0,$this->month, $totalDaysInThisMonth, $this->year));$i++) $output .= ""; } $output .= "
SMTWTFS
 "; else $output .= ""; $output .= "$i
 
Today : ".date("d M Y")."
"; print $output; } } ?>