Пример #1
0
 public function testVisitDateTimeDateTime()
 {
     $visitor = new ValidationVisitor();
     $property = Property::getDateTime('test');
     $this->assertTrue($visitor->visitDateTime(new \DateTime(), $property, ''));
 }
Пример #2
0
 public function visitDateTime($data, Property\DateTimeType $property, $path)
 {
     if ($this->validate) {
         parent::visitDateTime($data, $property, $path);
     } else {
         $this->assertRequired($data, $property, $path);
     }
     if ($data instanceof \DateTime) {
         return $this->createSimpleProperty($data, $property);
     }
     try {
         return $this->createSimpleProperty(new DateTime($data), $property);
     } catch (\Exception $e) {
         throw new ValidationException($path . ' must be an valid date-time format (full-date "T" full-time) [RFC3339]');
     }
 }