/**
  * @see sfValidatorBase
  */
 protected function doClean($value)
 {
     $from = $value["from"];
     $to = $value["to"];
     $inputDatePattern = sfContext::getInstance()->getUser()->getDateFormat();
     $datepickerDateFormat = get_datepicker_date_format($inputDatePattern);
     if ($from != $datepickerDateFormat && $to != $datepickerDateFormat) {
         try {
             $value["from"] = parent::doClean($value["from"]);
         } catch (Exception $exc) {
             try {
                 $value["to"] = parent::doClean($value["to"]);
             } catch (Exception $exc) {
                 $this->setMessage('invalid', 'Insert valid "from" and "to" date');
                 $this->setMessage("bad_format", "From date and To date values do not match the date format " . $datepickerDateFormat);
                 throw $exc;
             }
             $this->setMessage('invalid', 'Insert a valid "from" date');
             throw $exc;
         }
         try {
             $value["to"] = parent::doClean($value["to"]);
         } catch (Exception $exc) {
             $this->setMessage('invalid', 'Insert a valid "to" date');
             throw $exc;
         }
     } else {
         if ($from == $datepickerDateFormat && $to != $datepickerDateFormat) {
             if ($to != "") {
                 $value["to"] = parent::doClean($value["to"]);
                 $this->setMessage('invalid', 'Insert a valid "to" date');
                 $this->setMessage("bad_format", "To date value does not match the date format " . $datepickerDateFormat);
             }
         } else {
             if ($from != $datepickerDateFormat && $to == $datepickerDateFormat) {
                 if ($from != "") {
                     $value["from"] = parent::doClean($value["from"]);
                     $this->setMessage('invalid', 'Insert a valid "from" date');
                     $this->setMessage("bad_format", "From date value does not match the date format " . $datepickerDateFormat);
                 }
             } else {
                 if ($from == $datepickerDateFormat && $to == $datepickerDateFormat) {
                     return $value;
                 }
             }
         }
     }
     if ($value["from"] != $datepickerDateFormat && $value["to"] != $datepickerDateFormat && $value["from"] != "" && $value["to"] != "") {
         $this->setMessage('invalid', 'From date should be before to date.');
         $v = new ohrmValidatorSchemaDateRange("project_date_range", sfValidatorSchemaCompare::LESS_THAN_EQUAL, "project_date_range", array('throw_global_error' => true), array('invalid' => $this->getMessage('invalid')));
         $v->clean($value);
     }
     return $value;
 }