コード例 #1
0
ファイル: Collection.php プロジェクト: wallacemaxters/timer
 /**
  * Attaches a time object to collection
  * @param \WallaceMaxters\Timer\Time $time
  * @return  \Wallacemaxters\Timer\Collection
  * */
 public function attach(Time $time)
 {
     $time->setFormat($this->format);
     $this->add($time);
     return $this;
 }
コード例 #2
0
ファイル: Time.php プロジェクト: wallacemaxters/timer
 /**
  * Get a new instance of WallaceMaxters\Timer\Time of diff with another Time
  *
  * @param Time $time time for comparation
  * @param boolean $absolute
  * @return \WallaceMaxters\Timer\Time
  * */
 public function diff(Time $time, $absolute = true)
 {
     $diff = $this->getSeconds() - $time->getSeconds();
     return new self(0, 0, $absolute ? abs($diff) : $diff);
 }
コード例 #3
0
ファイル: TimeTest.php プロジェクト: wallacemaxters/timer
 public function testFormatNegativeSign()
 {
     // Positive
     $time = Time::createFromFormat('%h:%i:%s', '00:50:00');
     $this->assertEquals('00:50:00', $time->format('%r%h:%i:%s'));
     $this->assertEquals('+00:50:00', $time->format('%R%h:%i:%s'));
     // Negative
     $time2 = Time::createFromFormat('%R%h:%i:%s', '-02:00:00');
     $this->assertEquals('-02:00:00', $time2->format('%R%h:%i:%s'));
     $this->assertEquals('-02:00:00', $time2->format('%r%h:%i:%s'));
     // Positive with R
     $time = Time::createFromFormat('%R%h:%i:%s', '+22:00:00');
     $this->assertEquals('+22:00', $time->format('%R%h:%i'));
 }
コード例 #4
0
 public function testRemove()
 {
     $time1 = Time::create(0, 20);
     $c1 = Collection::create([$time1, 30, 40, 50]);
     $time2 = $c1[3];
     $deletes[] = $c1->remove($time1);
     $deletes[] = $c1->remove($time2);
     $this->assertEquals([0, 3], $deletes);
 }