/**
  * Helper method for converting from FormHelper options data to widget format.
  *
  * @param array $options Options to convert.
  * @return array Converted options.
  */
 protected function _datetimeOptions($options)
 {
     foreach ($this->_datetimeParts as $type) {
         if (!isset($options[$type])) {
             $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];
         }
     }
     unset($options['empty']);
     $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 (!isset($options['val'])) {
         $val = new IntlDateTime(null, null, 'persian');
         $currentYear = $val->format('Y');
         if (isset($options['year']['end']) && $options['year']['end'] < $currentYear) {
             $val->set($val->format($options['year']['end'] . '/MM/dd'));
         }
         $options['val'] = $val;
     }
     return $options;
 }
 function testModify()
 {
     $date = new IntlDateTime('1388/04/01', 'Asia/Tehran', 'persian');
     $date->modify('+1 month');
     $result = $date->format('yyyy/MM/dd HH:mm:ss');
     $this->assertEquals($result, '1388/05/01 00:00:00');
     $date->set('1387/11/01');
     $date->modify('+1 year');
     $result = $date->format('yyyy/MM/dd HH:mm:ss');
     $this->assertEquals($result, '1388/11/01 00:00:00');
     $date->set('1387/11/01 03:45');
     $date->modify('next year');
     $result = $date->format('yyyy/MM/dd HH:mm:ss');
     $this->assertEquals($result, '1388/11/01 03:45:00');
     $date->set('1388/11/01');
     $date->modify('-12 months');
     $result = $date->format('yyyy/MM/dd HH:mm:ss');
     $this->assertEquals($result, '1387/11/01 00:00:00');
     $date->set('1386/12/01');
     $date->modify('-4days +2years +3hours');
     $result = $date->format('yyyy/MM/dd HH:mm:ss');
     $this->assertEquals($result, '1388/11/27 03:00:00');
     $date->set('1388/07/01');
     $date->modify('+1hour +30days -1month');
     $result = $date->format('yyyy/MM/dd HH:mm:ss');
     $this->assertEquals($result, '1388/07/01 01:00:00');
 }