function date_all_day_date_combo_validate_date_end_alter in Date 7.3
Same name and namespace in other branches
- 8 date_all_day/date_all_day.module \date_all_day_date_combo_validate_date_end_alter()
- 7.2 date_all_day/date_all_day.module \date_all_day_date_combo_validate_date_end_alter()
Implements hook_date_combo_validate_date_end_alter().
File
- date_all_day/
date_all_day.module, line 335 - Adds All Day functionality to the Date field.
Code
function date_all_day_date_combo_validate_date_end_alter(&$date, &$form_state, $context) {
// This hook lets us alter the local date objects created by the date_combo
// validation before they are converted back to the database timezone and
// stored. If this is an 'All day' value, set the time as close to midnight as
// possible.
if (!empty($context['element']['#date_is_all_day'])) {
$increment = isset($context['instance']['widget']['settings']['increment']) ? $context['instance']['widget']['settings']['increment'] : 1;
// @todo Should this reduce by an additional 1 minute if the increment is
// more than 1? For example, if the increment is 15 should the upper value
// be 23:45:59 or 23:44:59?
$date
->setTime(23, 60 - $increment, 59);
}
}