You are here

protected function DateBase::getDateType in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Plugin/WebformElement/DateBase.php \Drupal\webform\Plugin\WebformElement\DateBase::getDateType()

Get the type of date/time element.

Parameters

array $element: An element.

Return value

string The type of date/time element which be either a 'date' or 'datetime'.

2 calls to DateBase::getDateType()
DateBase::buildExportRecord in src/Plugin/WebformElement/DateBase.php
Build an element's export row.
DateBase::parseInputFormat in src/Plugin/WebformElement/DateBase.php
Parse GNU Date Input Format.

File

src/Plugin/WebformElement/DateBase.php, line 387

Class

DateBase
Provides a base 'date' class.

Namespace

Drupal\webform\Plugin\WebformElement

Code

protected function getDateType(array $element) {
  switch ($element['#type']) {
    case 'datelist':
      return isset($element['#date_part_order']) && !in_array('hour', $element['#date_part_order']) ? 'date' : 'datetime';
    case 'datetime':
      return 'datetime';
    case 'date':
    default:
      return 'date';
  }
}