function calendar_part_is_valid in Calendar 7
Same name and namespace in other branches
- 5.2 calendar.module \calendar_part_is_valid()
- 5 calendar.module \calendar_part_is_valid()
- 6.2 calendar.module \calendar_part_is_valid()
- 7.2 calendar.module \calendar_part_is_valid()
A function to test the validity of various date parts
File
- ./
calendar.module, line 118 - Adds calendar filtering and displays to Views.
Code
function calendar_part_is_valid($value, $type) {
if (!preg_match('/^[0-9]*$/', $value)) {
return FALSE;
}
$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;
}