function calendar_week_range in Calendar 5
Get the start and end datestamp for a calendar week.
6 calls to calendar_week_range()
- 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.
- calendar_get_paths in ./
calendar.module - calendar_nav in ./
calendar.module - Function to construct back and next navigation from views arguments
- calendar_week in ./
calendar.module - Handle a lot of messy week calculations all in one place to make maintenance easier
- calendar_week_year in ./
calendar.module - Find the calendar week number and year for a date.
File
- ./
calendar.module, line 974 - Adds calendar filtering and displays to Views.
Code
function calendar_week_range($year, $week) {
calendar_load_date_api();
// Get timestamp for January 1 of the requested year.
$min_date = date_gmmktime(array(
'mon' => 1,
'mday' => 1,
'year' => $year,
));
// Adjust back or forward to the first day of the calendar week for the specified first day of week.
$dow = date_format_date('w', $min_date);
$first_day = variable_get('date_first_day', 0);
$diff = -((7 - $first_day + $dow) % 7);
$min_date += $diff * 86400;
// Add the requested number of weeks to that date.
$min_date += intval(($week - 1) * 604800);
// Find the end date, which is one week later, less one second.
$max_date = $min_date + 604800 - 1;
return array(
$min_date,
$max_date,
);
}