2. caculate method, calculate the number of days and style of the calendar
1) Calculate the number of days in the last month. If the first day of the month is not a Sunday, you need to calculate it based on the last day of the last month
2) Traverse the number of days in this month, and if it is a rest day, add a special css style
3) Calculate the number of days in the next month, divided into three situations, Sunday, Saturday and working days
Copy code
/**
* @author Pwstrick
* @param array $calendar Data calculated by threshold method
* @deprecated Calculate the number of days and style of the calendar
*/
function caculate($calendar) {
$days = $calendar['days'];
$firstDayOfWeek = $calendar['firstDayOfWeek'];//The first day of the week of this month
$lastDayOfWeek = $calendar['lastDayOfWeek'];//The week of the last day of this month
$lastMonthOfLastDay = $calendar['lastMonthOfLastDay'];//The last day of the previous month
$year = $calendar['year'];
$month = $calendar['month'];
$dates = array();
if($firstDayOfWeek != 7) {
$lastDays = array();
$current = $lastMonthOfLastDay;//The last day of the previous month
for ($i = 0; $i < $firstDayOfWeek; $i++) {
array_push($lastDays, $current);//Add the number of days in the previous month
$current--;
}
$lastDays = array_reverse($lastDays);//Reverse order
array_push($result, $tr);//Add to the returned data
$tr = array();//Clear the array list
}else {
array_push($tr, $date);
}
}
return $result;
}
http://www.bkjia.com/PHPjc/885672.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/885672.htmlTechArticlePHP self-made calendar 1. Calculate data 1. Create a new Calendar class 2. Initialize the data in the two drop-down boxes. Year and month 3. Initialize the year and month to be searched 4. Calculate the calendar...
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn