Exemple #1
0
 /**
  * @param Date $value
  * @param AbstractPlatform $platform
  *
  * @return string
  */
 public function convertToDatabaseValue($value, AbstractPlatform $platform)
 {
     if ($value instanceof Date) {
         return $value->toDateTime()->format($platform->getDateFormatString());
     }
     return parent::convertToDatabaseValue($value, $platform);
 }
Exemple #2
0
 public function testEarlierThan()
 {
     $object1 = Date::create(2005, 3, 11);
     $object2 = Date::createFromDateTime(new DateTime('2005-02-11'));
     static::assertFalse($object1->earlierThan($object2));
     $object1 = Date::create(2005, 2, 11);
     $object2 = Date::createFromDateTime(new DateTime('2005-02-11'));
     static::assertFalse($object1->earlierThan($object2));
     $object1 = Date::create(2005, 1, 11);
     $object2 = Date::createFromDateTime(new DateTime('2005-02-11'));
     static::assertTrue($object1->earlierThan($object2));
 }
 public function testEarlierThan()
 {
     $object1 = DateTimeOfDay::create(Date::create(2005, 10, 11), TimeOfDay::create(15, 13, 13));
     $object2 = DateTimeOfDay::create(Date::create(2005, 10, 11), TimeOfDay::create(15, 12, 13));
     static::assertFalse($object1->earlierThan($object2));
     $object1 = DateTimeOfDay::create(Date::create(2005, 10, 11), TimeOfDay::create(15, 12, 13));
     $object2 = DateTimeOfDay::create(Date::create(2005, 10, 11), TimeOfDay::create(15, 12, 13));
     static::assertFalse($object1->earlierThan($object2));
     $object1 = DateTimeOfDay::create(Date::create(2005, 10, 11), TimeOfDay::create(15, 11, 13));
     $object2 = DateTimeOfDay::create(Date::create(2005, 10, 11), TimeOfDay::create(15, 12, 13));
     static::assertTrue($object1->earlierThan($object2));
 }
 /**
  * @param DateTimeInterface $dateTime
  *
  * @return self
  */
 public static function createFromDateTime(DateTimeInterface $dateTime)
 {
     return static::create(Date::createFromDateTime($dateTime), TimeOfDay::createFromDateTime($dateTime));
 }
 public function validProvider()
 {
     return [[Date::create(2015, 6, 15), Date::create(2015, 6, 17), Duration::create(0, 0, 2, 0, 0, 0), '2015-06-15T00:00:00/2015-06-17T00:00:00'], [DateTimeOfDay::create(Date::create(2012, 6, 17), TimeOfDay::create(23, 1, 0)), DateTimeOfDay::create(Date::create(2015, 6, 17), TimeOfDay::create(23, 2, 0)), Duration::create(3, 0, 0, 0, 1, 0)], [Date::create(2015, 6, 15), Duration::create(0, 1, 5, 0, 0, 0), Duration::create(0, 1, 5, 0, 0, 0)], [Duration::create(0, 5, 12, 0, 0, 0), Date::create(2015, 6, 17), Duration::create(0, 5, 12, 0, 0, 0), '2015-01-05T00:00:00/2015-06-17T00:00:00']];
 }
 /**
  * @return array
  */
 public function validProvider()
 {
     return [[Date::create(2015, 6, 15), Duration::create(0, 0, 2, 0, 0, 0), 5, 'R5/2015-06-15T00:00:00Z/P2D']];
 }
 /**
  * @dataProvider validProvider
  * @expectedException \Zelenin\Ddd\Core\Domain\Exception\NotMatchTypeException
  */
 public function testEqualsNotSameType($year, $month, $day, $hour, $minute, $second, $iso8601format)
 {
     $object1 = Duration::create($year, $month, $day, $hour, $minute, $second);
     $object2 = Date::create(1, 1, 1);
     $object1->equalsTo($object2);
 }