1 date.elements.inc _date_html5_get_date_limits(array $limit_settings)

Helper function to get widget settings for date limits.

Parameters

array $limit_settings: Widget settings for date limits.

Return value

array:

File

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

Code

function _date_html5_get_date_limits(array $limit_settings) {
  $date_limits = array(
    'min' => NULL,
    'max' => NULL,
  );
  if ($limit_settings['mode'] == 'byyear') {
    $now = date_now();
    if ($limit_settings['years_back'] !== '') {
      $min_year = (int) $now->format('Y') + $limit_settings['years_back'];
      $date_limits['min'] = $min_year . '-01-01';
    }
    if ($limit_settings['years_forward'] !== '') {
      $max_year = (int) $now->format('Y') + $limit_settings['years_forward'];
      $date_limits['max'] = $max_year . '-12-31';
    }
  }

  return $date_limits;
}