1 date.elements.inc _date_html5_get_default_value(array $field, array $instance, $langcode)

Helper function to return default values as expected by the form item.

Parameters

array $field: Field structure.

array $instance: Field instance structure.

string $langcode: Language code.

Return value

array:

File

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

Code

function _date_html5_get_default_value(array $field, array $instance, $langcode) {
  $default = array(
    'start' => NULL,
    'end' => NULL,
  );
  $granularity = $field['settings']['granularity'];
  $date_defaults = date_default_value($field, $instance, $langcode);
  $values = reset($date_defaults);
  $timezone_db = $values['timezone_db'];
  $timezone = $values['timezone'];
  $type = empty($granularity['hour']) ? 'html_date' : 'html_datetime';
  $timestep = empty($granularity['second']) ? 60 : 1;

  if (!empty($values['value'])) {
    $default['start'] = _date_html5_get_form_value($values['value'], $type, $timestep, $timezone_db, $timezone);
  }
  if (!empty($values['value2'])) {
    $default['end'] = _date_html5_get_form_value($values['value2'], $type, $timestep, $timezone_db, $timezone);
  }

  return $default;
}