示例#1
0
 /**
  * Checks whether or not the given DateTime object is within this range
  *
  * @param A_Datetime $datetime DateTime object to check
  * @param bool $inclusive Set to true to include start and end in range
  * @return bool
  */
 public function contains($datetime, $inclusive = false)
 {
     if ($datetime instanceof A_Datetime) {
         if ($inclusive) {
             return $datetime->getTimestamp() >= $this->start->getTimestamp() && $datetime->getTimestamp() <= $this->end->getTimestamp();
         } else {
             return $datetime->getTimestamp() > $this->start->getTimestamp() && $datetime->getTimestamp() < $this->end->getTimestamp();
         }
     }
 }
示例#2
0
 function testRemoveReturnsNewDate()
 {
     $date = new A_Datetime();
     $duration = new MockA_Datetime_Duration();
     $duration->setReturnValue('toString', '-1 days');
     $duration->expectOnce('setNegative');
     $duration->expectOnce('toString');
     $date2 = $date->remove($duration);
     $this->assertEqual($date2->getTimestamp(), strtotime('-1 day', $date->getTimestamp()));
 }