Exemplo n.º 1
0
 public function testNextEquals()
 {
     $startDate = new Date(2012, 01, 01);
     $endDate = new Date(2012, 01, 03);
     $interval = new DateInterval($startDate, $endDate);
     $this->assertEquals($startDate, $interval->getBegin());
     $this->assertEquals(new Date(2012, 01, 02), $interval->getBegin()->next());
     $this->assertEquals(new Date(2012, 01, 03), $interval->getBegin()->next()->next());
     $this->assertFalse($endDate->isEquals($interval->getBegin()));
     $this->assertFalse($endDate->isEquals($interval->getBegin()->next()));
     $this->assertTrue($endDate->isEquals($interval->getBegin()->next()->next()));
 }
Exemplo n.º 2
0
 public static function fromDateInterval(DateInterval $dateInterval)
 {
     $begin = $dateInterval->getBegin();
     $end = $dateInterval->getEnd();
     return new TimeInterval(new TimePoint($begin->getYear(), $begin->getMonth(), $begin->getDay(), 0, 0), new TimePoint($end->getYear(), $end->getMonth(), $end->getDay(), 23, 59, 59));
 }