Exemple #1
0
 /**
  * Returns the total elapsed time.
  *
  * This includes the times between previous start() and stop() calls if any,
  * as well as the time since the stopwatch was last started if it is running.
  *
  * @return Duration
  */
 public function getElapsedTime()
 {
     if ($this->startTime === null) {
         return $this->duration;
     }
     return $this->duration->plus(Duration::between($this->startTime, Instant::now()));
 }
 public function test_equals()
 {
     $a = Clock::systemUTC();
     $b = Clock::systemUTC();
     $this->assertEquals($a->equals($a), true);
     $this->assertEquals($a->equals($b), true);
     $this->assertEquals($b->equals($a), true);
     $this->assertEquals($b->equals($b), true);
     $c = Clock::system(self::PARIS());
     $d = Clock::system(self::PARIS());
     $this->assertEquals($c->equals($c), true);
     $this->assertEquals($c->equals($d), true);
     $this->assertEquals($d->equals($c), true);
     $this->assertEquals($d->equals($d), true);
     $this->assertEquals($a->equals($c), false);
     $this->assertEquals($c->equals($a), false);
     $this->assertEquals($a->equals(null), false);
     $this->assertEquals($a->equals("other type"), false);
     $this->assertEquals($a->equals(Clock::fixed(Instant::now(), ZoneOffset::UTC())), false);
 }
Exemple #3
0
 /**
  * Returns whether this instant is in the past.
  *
  * @return boolean
  */
 public function isPast()
 {
     return $this->isBefore(Instant::now());
 }