You are here

function date_popup_input_value in Date 6

Same name and namespace in other branches
  1. 5.2 date_popup/date_popup.module \date_popup_input_value()
  2. 6.2 date_popup/date_popup.module \date_popup_input_value()

Helper function for extracting a date value out of user input.

1 call to date_popup_input_value()
date_popup_validate in date_popup/date_popup.module
Massage the input values back into a single date.

File

date_popup/date_popup.module, line 329
A module to enable jquery calendar and time entry popups. Requires the Date API.

Code

function date_popup_input_value($element) {
  $input = $element['#value']['date'];
  if (!empty($element['#value']['time'])) {
    $input .= ' ' . $element['#value']['time'];
  }
  date_popup_load();
  $granularity = date_format_order($element['#date_format']);
  $value = date_convert_from_custom($input, date_limit_format($element['#date_format'], $granularity));
  if (date_is_valid($value, DATE_DATETIME)) {
    $date = date_make_date($value, $element['#date_timezone'], DATE_DATETIME);
    $value = date_convert($date, DATE_OBJECT, DATE_DATETIME);
    return $value;
  }
  return NULL;
}