public function testGetConvertedValueLessThan()
 {
     $value = new \DateTime('2014-01-01', new \DateTimeZone('UTC'));
     $result = $this->converter->getConvertedValue([], ['value' => ['end' => $value, 'start' => null], 'type' => AbstractDateFilterType::TYPE_LESS_THAN]);
     $this->assertEquals(FilterDateTimeRangeConverter::MIN_DATE, $result['start']->format('Y-m-d'));
     $this->assertEquals($value, $result['end']);
 }
 /**
  * {@inheritdoc}
  */
 public function getConvertedValue(array $widgetConfig, $value = null, array $config = [], array $options = [])
 {
     $result = [];
     if ($value === null && $config['converter_attributes']['default_checked'] === true || $value) {
         if (!isset($config['converter_attributes']['dateRangeField'])) {
             throw new \Exception('Previous date range configuration parameter should have dateRangeField attribute');
         }
         $currentDateRange = $options[$config['converter_attributes']['dateRangeField']];
         if (isset($currentDateRange['value'])) {
             $currentDateRange = parent::getConvertedValue($widgetConfig, $currentDateRange, $config, $options);
         }
         if ($currentDateRange['type'] !== AbstractDateFilterType::TYPE_LESS_THAN) {
             /**
              * @var \DateTime $from
              * @var \DateTime $to
              */
             $from = $currentDateRange['start'];
             $to = $currentDateRange['end'];
             $interval = $from->diff($to);
             $fromDate = clone $from;
             $result['start'] = $fromDate->sub($interval);
             $result['end'] = clone $from;
             $result['type'] = AbstractDateFilterType::TYPE_BETWEEN;
         }
     }
     return $result;
 }
 /**
  * {@inheritdoc}
  */
 public function getConvertedValue(array $widgetConfig, $value = null, array $config = [], array $options = [])
 {
     $result = [];
     if ($value === null && $config['converter_attributes']['default_checked'] === true || $value) {
         if (!isset($config['converter_attributes']['dateRangeField'])) {
             throw new \Exception('Previous date range configuration parameter should have dateRangeField attribute');
         }
         $currentDateRange = $options[$config['converter_attributes']['dateRangeField']];
         if (isset($currentDateRange['value'])) {
             $currentDateRange = parent::getConvertedValue($widgetConfig, $currentDateRange, $config, $options);
         }
         if ($currentDateRange['type'] !== AbstractDateFilterType::TYPE_LESS_THAN) {
             list($start, $end) = $this->dateHelper->getPreviousDateTimeInterval($currentDateRange['start'], $currentDateRange['end']);
             $result['start'] = $start;
             $result['end'] = $end;
             $result['type'] = AbstractDateFilterType::TYPE_BETWEEN;
         }
     }
     return $result;
 }