function calendar_part_is_valid in Calendar 5
Same name and namespace in other branches
- 5.2 calendar.module \calendar_part_is_valid()
- 6.2 calendar.module \calendar_part_is_valid()
- 7 calendar.module \calendar_part_is_valid()
- 7.2 calendar.module \calendar_part_is_valid()
A function to test the validity of various date parts
8 calls to calendar_part_is_valid()
- calendar_filter_day in ./
calendar.module - Callback for day filter. Build year, month, day, min, and max into query object.
- calendar_filter_month in ./
calendar.module - Callback for month filter. Build year, month, day, min, and max into query object.
- calendar_filter_week in ./
calendar.module - Callback for week filter. Build year, month, day, min, and max into query object.
- calendar_filter_year in ./
calendar.module - Callback for year filter. Build year, month, day, min, and max into query object.
- 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 1067 - Adds calendar filtering and displays to Views.
Code
function calendar_part_is_valid($value, $type) {
if (!preg_match('/^[0-9]*$/', $value)) {
return false;
}
calendar_load_date_api();
$value = intval($value);
if ($value <= 0) {
return false;
}
switch ($type) {
case 'year':
if ($value < DATE_MIN_YEAR) {
return false;
}
break;
case 'month':
if ($value < 0 || $value > 12) {
return false;
}
break;
case 'day':
if ($value < 0 || $value > 31) {
return false;
}
break;
case 'week':
if ($value < 0 || $value > 53) {
return false;
}
}
return true;
}