Options: * "input": The type of the normalized format ("time" or "timestamp"). Default: "datetime" * "output": The type of the transformed format ("string" or "array"). Default: "string" * "format": The format of the time string ("short", "medium", "long" or "full"). Default: "short"
Author: Bernhard Schussek (bernhard.schussek@symfony.com)
Author: Florian Eckerstorfer (florian@eckerstorfer.org)
Inheritance: extends Symfony\Component\Form\Extension\Core\DataTransformer\BaseDateTimeTransformer
 /**
  * @param string $dateRangeString
  *
  * @return null|DateRange
  */
 public function reverseTransform($dateRangeString)
 {
     if (!$dateRangeString) {
         return null;
     }
     $dateRangeArray = explode($this->separator, $dateRangeString);
     $start = $this->dateTimeTransformer->reverseTransform($dateRangeArray[0]);
     $end = $this->dateTimeTransformer->reverseTransform($dateRangeArray[1]);
     return new DateRange($start, $end);
 }
 public function getDisplayedValue($value)
 {
     if (!empty($value)) {
         $dateTime = $this->getDatetime($value, new \DateTimeZone($this->getTimezone()));
         if (isset($this->format)) {
             $value = $dateTime->format($this->format);
         } else {
             try {
                 $transformer = new DateTimeToLocalizedStringTransformer(null, $this->getTimezone(), $this->dateFormat, $this->timeFormat);
                 $value = $transformer->transform($dateTime);
             } catch (\Exception $e) {
                 $value = $dateTime->format($this->fallbackFormat);
             }
         }
         if (key_exists((string) $value, $this->values)) {
             $value = $this->values[$value];
         }
         return $value;
     }
     return '';
 }
 /**
  * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
  */
 public function testReverseTransformWithNonExistingDate()
 {
     $transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', \IntlDateFormatter::SHORT);
     $this->assertDateTimeEquals($this->dateTimeWithoutSeconds, $transformer->reverseTransform('31.04.10 04:05'));
 }
 /**
  * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException
  */
 public function testReverseTransformOutOfTimestampRange()
 {
     $transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC');
     $transformer->reverseTransform('1789-07-14');
 }
 /**
  * @expectedException Symfony\Component\Form\Exception\TransformationFailedException
  */
 public function testReverseTransformWrapsIntlErrors()
 {
     $transformer = new DateTimeToLocalizedStringTransformer();
     $transformer->reverseTransform('12345', null);
 }
    public function testReverseTransformWrapsIntlErrors()
    {
        $transformer = new DateTimeToLocalizedStringTransformer();

        $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException');

        $transformer->reverseTransform('12345', null);
    }