protected function _datetimeOptions($options)
{
foreach ($this->_datetimeParts as $type) {
if (!array_key_exists($type, $options)) {
$options[$type] = [];
}
if ($options[$type] === true) {
$options[$type] = [];
}
// Pass empty options to each type.
if (!empty($options['empty']) && is_array($options[$type])) {
$options[$type]['empty'] = $options['empty'];
}
// Move empty options into each type array.
if (isset($options['empty'][$type])) {
$options[$type]['empty'] = $options['empty'][$type];
}
}
$hasYear = is_array($options['year']);
if ($hasYear && isset($options['minYear'])) {
$options['year']['start'] = $options['minYear'];
}
if ($hasYear && isset($options['maxYear'])) {
$options['year']['end'] = $options['maxYear'];
}
if ($hasYear && isset($options['orderYear'])) {
$options['year']['order'] = $options['orderYear'];
}
unset($options['minYear'], $options['maxYear'], $options['orderYear']);
if (is_array($options['month'])) {
$options['month']['names'] = $options['monthNames'];
}
unset($options['monthNames']);
if (is_array($options['hour']) && isset($options['timeFormat'])) {
$options['hour']['format'] = $options['timeFormat'];
}
unset($options['timeFormat']);
if (is_array($options['minute'])) {
$options['minute']['interval'] = $options['interval'];
$options['minute']['round'] = $options['round'];
}
unset($options['interval'], $options['round']);
if ($options['val'] === true || $options['val'] === null && isset($options['empty']) && $options['empty'] === false) {
$val = new DateTime();
$currentYear = $val->format('Y');
if (isset($options['year']['end']) && $options['year']['end'] < $currentYear) {
$val->setDate($options['year']['end'], $val->format('n'), $val->format('j'));
}
$options['val'] = $val;
}
unset($options['empty']);
return $options;
}