Exemple #1
0
 /** @test */
 public function it_can_translate_values()
 {
     $loom = new Loom(new \Loom\Seconds(60));
     $this->assertEquals(60000, $loom->getMilliseconds());
     $this->assertEquals(60, $loom->getSeconds());
     $this->assertEquals(1, $loom->getMinutes());
     $loom = new Loom(new \Loom\Hours(24));
     $this->assertEquals(1, $loom->getDays());
     $this->assertEquals(1 / 7, $loom->getWeeks());
     $loom = new Loom(new \Loom\Years(1));
     $this->assertEquals(12, $loom->getMonths());
     $this->assertEquals(365, $loom->getDays());
     $loom = new Loom(new \Loom\Days(2));
     $this->assertEquals(48, $loom->getHours());
 }
Exemple #2
0
 /**
  * Is between two units
  *
  * @param Loom $start
  * @param Loom $end
  * @param bool $inclusive
  *
  * @return bool
  */
 public function isBetween(Loom $start, Loom $end, $inclusive = false)
 {
     $startMs = $start->getMilliseconds();
     $endMs = $end->getMilliseconds();
     if ($inclusive) {
         return $this->getMilliseconds() >= $startMs && $this->getMilliseconds() <= $endMs;
     }
     return $this->getMilliseconds() > $startMs && $this->getMilliseconds() < $endMs;
 }
 /**
  * Make a copy of the Loom object
  *
  * @param Loom $loom
  *
  * @return mixed
  */
 public function fromLoom(Loom $loom)
 {
     return $this->createLoom(new Milliseconds($loom->getMilliseconds()));
 }