function _calendar_limit_nodes in Calendar 5
A function to adjust node values to slice off times before and after the selected view used for calendars that span days, months, or years since the calendar api automatically creates additional calendars for calendars that extend into another time period and the additional calendars will be incomplete (only containing cross-over calendars)
1 call to _calendar_limit_nodes()
- calendar_get_nodes in ./
calendar.module - The workhorse function that takes the beginning array of items and alters it to an array of calendar nodes that the theme can handle.
File
- ./
calendar.module, line 501 - Adds calendar filtering and displays to Views.
Code
function _calendar_limit_nodes($nodes, $type, $year, $month, $day, $week, $offset) {
calendar_load_date_api();
if (!calendar_part_is_valid($day, 'day')) {
$day = 1;
}
if (!calendar_part_is_valid($month, 'month')) {
$month = date_format_date('m', date_time());
}
if (!calendar_part_is_valid($year, 'year')) {
$year = date_format_date('Y', date_time());
}
switch ($type) {
case 'day':
$min_date = date_gmmktime(array(
'mon' => $month,
'mday' => $day,
'year' => $year,
));
$max_date = $min_date + 86400 - 1;
break;
case 'week':
return calendar_week_range($year, $week);
case 'month':
$min_date = date_gmmktime(array(
'mon' => $month,
'mday' => 1,
'year' => $year,
));
// find the first day of the next month and subtract one day
if (intval($month) < 12) {
$max_date = date_gmmktime(array(
'mon' => intval($month + 1),
'day' => 1,
'year' => $year,
'hours' => 23,
'minutes' => 59,
'seconds' => 59,
));
}
else {
$max_date = date_gmmktime(array(
'mon' => 1,
'mday' => 1,
'year' => intval($year + 1),
'hours' => 23,
'minutes' => 59,
'seconds' => 59,
));
}
$max_date -= 86400;
break;
case 'year':
$min_date = date_gmmktime(array(
'hours' => 0,
'minutes' => 0,
'seconds' => 0,
'mon' => 1,
'mday' => 1,
'year' => $year,
));
$max_date = date_gmmktime(array(
'hours' => 23,
'minutes' => 59,
'seconds' => 59,
'mon' => 12,
'mday' => 31,
'year' => $year,
));
}
return array(
$min_date,
$max_date,
);
}