public function testPositiveDuration()
 {
     $duration = new Duration('P3Y4DT6H8M');
     // 2 years, 4 days, 6 hours, 8 minutes.
     $this->assertEquals(3, $duration->getYears());
     $this->assertEquals(4, $duration->getDays());
     $this->assertEquals(6, $duration->getHours());
     $this->assertEquals(8, $duration->getMinutes());
     $this->assertEquals(0, $duration->getMonths());
     $this->assertEquals(0, $duration->getSeconds());
 }
 /**
  * Whether the duration described by this Duration object is longer than or
  * equal to the one described by $duration.
  * 
  * @param Duration $duration A Duration object to compare with this one.
  * @return boolean
  */
 public function longerThanOrEquals(Duration $duration)
 {
     if ($this->getYears() < $duration->getYears()) {
         return false;
     } else {
         if ($this->getMonths() < $duration->getMonths()) {
             return false;
         } else {
             if ($this->getDays() < $duration->getDays()) {
                 return false;
             } else {
                 if ($this->getHours() < $duration->getHours()) {
                     return false;
                 } else {
                     if ($this->getMinutes() < $duration->getMinutes()) {
                         return false;
                     } else {
                         if ($this->getSeconds() < $duration->getSeconds()) {
                             return false;
                         } else {
                             return true;
                         }
                     }
                 }
             }
         }
     }
 }
Beispiel #3
0
 /**
  * Whether the duration described by this Duration object is longer than or
  * equal to the one described by $duration.
  *
  * @param \qtism\common\datatypes\Duration $duration A Duration object to compare with this one.
  * @return boolean
  */
 public function longerThanOrEquals(Duration $duration)
 {
     return $this->getSeconds(true) >= $duration->getSeconds(true);
 }