1 date.elements.inc date_select_element_value_callback($element, $input = FALSE, &$form_state = array())

Element value callback for date_select element.

File

core/modules/date/date.elements.inc, line 483
Date forms and form themes and validation.

Code

function date_select_element_value_callback($element, $input = FALSE, &$form_state = array()) {
  $return = array(
    'year' => '',
    'month' => '',
    'day' => '',
    'hour' => '',
    'minute' => '',
    'second' => '',
  );
  $date = NULL;
  if ($input !== FALSE) {
    $return = $input;
    $date = date_select_input_date($element, $input);
  }
  elseif (!empty($element['#default_value'])) {
    $date = date_default_date($element);
  }
  $granularity = date_format_order($element['#date_format']);
  $formats = array(
    'year' => 'Y',
    'month' => 'n',
    'day' => 'j',
    'hour' => 'H',
    'minute' => 'i',
    'second' => 's',
  );
  foreach ($granularity as $field) {
    if ($field != 'timezone') {
      $return[$field] = date_is_date($date) ? $date->format($formats[$field]) : '';
    }
  }
  return $return;
}