You are here

function date_select_input_date in Date 7

Same name and namespace in other branches
  1. 7.3 date_api/date_api_elements.inc \date_select_input_date()
  2. 7.2 date_api/date_api_elements.inc \date_select_input_date()

Helper function for creating a date object out of user input.

3 calls to date_select_input_date()
date_select_element_process in date_api/date_api_elements.inc
Flexible date/time drop-down selector.
date_select_element_value_callback in date_api/date_api_elements.inc
Element value callback for date_select element.
date_select_validate in date_api/date_api_elements.inc
Validation function for date selector.
1 string reference to 'date_select_input_date'
date_input_date in ./date.module

File

date_api/date_api_elements.inc, line 560
Date API elements themes and validation. This file is only included during the edit process to reduce memory usage.

Code

function date_select_input_date($element, $input) {
  if (empty($input) || !is_array($input) || !array_key_exists('year', $input) || empty($input['year'])) {
    return NULL;
  }
  $granularity = date_format_order($element['#date_format']);
  $date = new DateObject($input, $element['#date_timezone']);
  if (is_object($date)) {
    $date
      ->limitGranularity($granularity);
    if ($date
      ->validGranularity($granularity, $element['#date_flexible'])) {
      date_increment_round($date, $element['#date_increment']);
      return $date;
    }
  }
  return NULL;
}