示例#1
0
 public function testGreater()
 {
     $point = new TimePoint(2012, 2, 1, 1, 0, 30);
     // second
     $this->assertTrue($point->isAfter(new TimePoint(2012, 2, 1, 1, 0, 29)));
     $this->assertFalse($point->isAfter(new TimePoint(2012, 2, 1, 1, 0, 30)));
     $this->assertFalse($point->isAfter(new TimePoint(2012, 2, 1, 1, 0, 31)));
 }
示例#2
0
 public function testHowToConvertADddTimePointObjectIntoRegularDateTimeobject()
 {
     $timepoint = new TimePoint(2013, 3, 12, 18, 27, 11);
     $datetime = new \DateTime();
     $datetime->setDate(2013, 3, 12);
     $datetime->setTime(18, 27, 11);
     $this->assertEquals($timepoint->toDateTime(), $datetime);
 }
示例#3
0
 /**
  * @param TimePoint      $begin
  * @param null|TimePoint $end
  *
  * @return array
  */
 private function getEvents(TimePoint $begin, TimePoint $end = null)
 {
     $events = $this->events;
     $offset = 0;
     foreach ($events as $event) {
         if ($event->getInterval()->getEnd()->isAfter($begin) || $event->getInterval()->getEnd()->isEquals($begin)) {
             break;
         } else {
             $offset++;
         }
     }
     $events = array_slice($events, $offset);
     if (null === $end) {
         return $events;
     }
     $length = count($events);
     foreach (array_reverse($events) as $event) {
         if ($end->isAfter($event->getInterval()->getBegin())) {
             break;
         } else {
             $length--;
         }
     }
     return array_slice($events, 0, $length);
 }