/**
  * @param  array|string  $value      Date/Time passed as an array or a string
  * @var    string        $checkDateStructure: Get an empty string if the date structure is correct, otherwise get the error
  * @var    FuzzyDateTime $clean: A FuzzyDateTime object containing the date/time corrected and the associated mask
  * @return FuzzyDateTime $clean
  * @see    sfValidatorBase
  */
 protected function doClean($value)
 {
     if (is_array($value)) {
         try {
             // Check date time structure
             $checkDateStructure = FuzzyDateTime::checkDateTimeStructure($value);
         } catch (Exception $e) {
             throw new sfValidatorError($this, 'invalid', array('value' => $value));
         }
         if (!empty($checkDateStructure)) {
             throw new sfValidatorError($this, $checkDateStructure, array('value' => $value));
         }
         try {
             $clean = new FuzzyDateTime($value, FuzzyDateTime::getMaskFromDate($value), $this->getOption('from_date'), $this->getOption('with_time'));
         } catch (Exception $e) {
             throw new sfValidatorError($this, 'invalid', array('value' => $value));
         }
     } else {
         if ($regex = $this->getOption('date_format')) {
             // ...and that it can be extracted from string
             if (!preg_match($regex, $value, $match)) {
                 throw new sfValidatorError($this, 'bad_format', array('value' => $value, 'date_format' => $this->getOption('date_format_error') ? $this->getOption('date_format_error') : $this->getOption('date_format')));
             }
             $clean = new FuzzyDateTime($match);
         } else {
             try {
                 $clean = new FuzzyDateTime($value);
             } catch (Exception $e) {
                 throw new sfValidatorError($this, 'invalid', array('value' => $value));
             }
         }
     }
     // Check date is between min and max values given
     if ($this->hasOption('max') && $clean > $this->getOption('max')) {
         throw new sfValidatorError($this, 'max', array('value' => $value, 'max' => $this->getOption('max')));
     }
     if ($this->hasOption('min') && $clean < $this->getOption('min')) {
         throw new sfValidatorError($this, 'min', array('value' => $value, 'min' => $this->getOption('min')));
     }
     return $clean;
 }
$t->is($fdt->getDateMasked(), '24/02/1975 13:12:11', 'The date displayed is well with a complete mask');
$fdt->setMask(48);
$t->is($fdt->getDateMasked('strong'), '<strong>24</strong>/02/1975 <strong>13:12:11</strong>', 'The date displayed is well with a tag changing');
$t->is($fdt->getDateMasked('em', 'y-d-m-s-i-g'), '75-<em>24</em>-02-<em>11-12-1</em>', 'The date displayed is well with another format');
$t->is(FuzzyDateTime::checkDateTimeStructure($testArray), '', 'Date structure test ok');
$testArray['year'] = '1975';
$t->is(FuzzyDateTime::checkDateTimeStructure($testArray), '', 'Date structure test ok');
$testArray['day'] = '24';
$t->is(FuzzyDateTime::checkDateTimeStructure($testArray), 'month_missing', 'Date structure test ok');
$testArray['year'] = '';
$t->is(FuzzyDateTime::checkDateTimeStructure($testArray), 'year_missing', 'Date structure test ok');
$testArray['year'] = '1975';
$testArray['month'] = '02';
$testArray['day'] = '';
$testArray['hour'] = '02';
$t->is(FuzzyDateTime::checkDateTimeStructure($testArray), 'day_missing', 'Date structure test ok');
$testArray['year'] = '0001';
$testArray['month'] = '01';
$testArray['day'] = '01';
$fdt = new FuzzyDateTime($testArray);
$t->is($fdt->format('d/m/Y'), '01/01/0001', 'Date lower bound format ok');
$testArray = array('year' => '', 'month' => '', 'day' => '', 'hour' => '', 'minute' => '', 'second' => '');
$fdt = new FuzzyDateTime('2009/12/05');
$t->is_deeply($fdt->getDateTimeMaskedAsArray(), $testArray, 'array is the same');
$testArray = array('year' => 2009, 'month' => 12, 'day' => '', 'hour' => '', 'minute' => '', 'second' => '');
$fdt->setMask(48);
$t->is_deeply($fdt->getDateTimeMaskedAsArray(), $testArray, 'array is the same');
$testArray = array('year' => 2009, 'month' => 12, 'day' => 05, 'hour' => '', 'minute' => '', 'second' => '');
$fdt->setMask(56);
$t->is_deeply($fdt->getDateTimeMaskedAsArray(), $testArray, 'array is the same');
$testArray = array('year' => 2009, 'month' => 2);