function date_all_day_field in Date 8
Same name and namespace in other branches
- 7.3 date_all_day/date_all_day.module \date_all_day_field()
- 7.2 date_all_day/date_all_day.module \date_all_day_field()
Determine if a Start/End date combination qualify as 'All day'.
Parameters
array $field, the field definition for this date field.:
object $date1, a date/time object for the 'Start' date.:
object $date2, a date/time object for the 'End' date.:
Return value
TRUE or FALSE.
3 calls to date_all_day_field()
- date_all_day_date_formatter_dates_alter in date_all_day/
date_all_day.module - Implements hook_date_formatter_dates_alter().
- hook_date_formatter_dates_alter in ./
date.api.php - Alter the dates array created by date_formatter_process().
- theme_date_all_day in date_all_day/
date_all_day.module - Adjust start/end date format to account for 'all day' .
File
- date_all_day/
date_all_day.module, line 157 - Adds All Day functionality to the Date field.
Code
function date_all_day_field($field, $instance, $date1, $date2 = NULL) {
if (empty($date1) || !$date1 instanceof DrupalDateTime) {
return FALSE;
}
elseif (!DateGranularity::hasTime($field['settings']['granularity'])) {
return TRUE;
}
if (empty($date2)) {
$date2 = $date1;
}
$granularity = DateGranularity::precision($field['settings']['granularity']);
$increment = isset($instance['widget']['settings']['increment']) ? $instance['widget']['settings']['increment'] : 1;
return date_is_all_day(date_format($date1, DATE_FORMAT_DATETIME), date_format($date2, DATE_FORMAT_DATETIME), $granularity, $increment);
}