Retrieves the right format for a HTML5 date element.
The format is important because these elements will not work with any other format.
string $part: The type of element format to retrieve.
string $element: The $element to assess.
string Returns the right format for the type of element, or the original format if this is not a HTML5 element.
function datetime_html5_format($part, $element) {
$format_type = datetime_default_format_type();
switch ($part) {
case 'date':
switch ($element['#date_date_element']) {
case 'date':
return config('system.date')
->get('formats.html_date.pattern.' . $format_type);
case 'datetime':
case 'datetime-local':
return config('system.date')
->get('formats.html_datetime.pattern.' . $format_type);
default:
return $element['#date_date_format'];
}
break;
case 'time':
switch ($element['#date_time_element']) {
case 'time':
return config('system.date')
->get('formats.html_time.pattern.' . $format_type);
default:
return $element['#date_time_format'];
}
break;
}
}