function date_popup_input_date in Date 7
Same name and namespace in other branches
- 7.3 date_popup/date_popup.module \date_popup_input_date()
- 7.2 date_popup/date_popup.module \date_popup_input_date()
Helper function for extracting a date value out of user input.
Parameters
autocomplete: Should we add a time value to complete the date if there is no time? Useful anytime the time value is optional.
2 calls to date_popup_input_date()
- date_popup_element_value_callback in date_popup/
date_popup.module - Element value callback for date_popup element.
- date_popup_validate in date_popup/
date_popup.module - Massage the input values back into a single date.
1 string reference to 'date_popup_input_date'
File
- date_popup/
date_popup.module, line 416 - A module to enable jquery calendar and time entry popups. Requires the Date API.
Code
function date_popup_input_date($element, $input, $auto_complete = FALSE) {
if (empty($input) || !is_array($input) || !array_key_exists('date', $input) || empty($input['date'])) {
return NULL;
}
date_popup_add();
$granularity = date_format_order($element['#date_format']);
$has_time = date_has_time($granularity);
$flexible = !empty($element['#date_flexible']) ? $element['#date_flexible'] : 0;
$format = date_popup_date_format($element);
$format .= $has_time ? ' ' . date_popup_time_format($element) : '';
$datetime = $input['date'];
$datetime .= $has_time ? ' ' . $input['time'] : '';
$date = new DateObject($datetime, $element['#date_timezone'], $format);
if (is_object($date)) {
$date
->limitGranularity($granularity);
if ($date
->validGranularity($granularity, $flexible)) {
date_increment_round($date, $element['#date_increment']);
return $date;
}
}
return NULL;
}