Example #1
0
 /**
  * Tests RW_Time::subTime()
  */
 public function testSubTime()
 {
     $time = new RW_Time(61);
     $this->assertSame(61 - 13, $time->setTime(61)->subTime(13)->getSeconds());
     $this->assertSame(61 - 13 * 60, $time->setTime(61)->subTime(13, RW_Time::MINUTE)->getSeconds());
     $this->assertSame(61 - 13 * 60, $time->setTime(61)->subTime(13, RW_Time::MINUTE)->getSeconds());
     $this->assertSame(61 - 13 * 60, $time->setTime(61)->subTime('13:00')->getSeconds());
     $this->assertSame(61 - 13 * 60 * 60, $time->setTime(61)->subTime(13, RW_Time::HOUR)->getSeconds());
     $this->assertSame(61 - 13 * 60 * 60, $time->setTime(61)->subTime('13:00:00')->getSeconds());
     $time = new RW_Time('27:3');
     $this->assertSame(27 * 60 + 3 - 13, $time->setTime('27:3')->subTime(13)->getSeconds());
     $this->assertSame(27 * 60 + 3 - 13 * 60, $time->setTime('27:3')->subTime(13, RW_Time::MINUTE)->getSeconds());
     $this->assertSame(27 * 60 + 3 - 13 * 60, $time->setTime('27:3')->subTime('13:00')->getSeconds());
     $this->assertSame(27 * 60 + 3 - 13 * 60 * 60, $time->setTime('27:3')->subTime(13, RW_Time::HOUR)->getSeconds());
     $this->assertSame(27 * 60 + 3 - 13 * 60 * 60, $time->setTime('27:3')->subTime('13:00:00')->getSeconds());
     $time = new RW_Time('27:3', 'h:m');
     $this->assertSame(27 * 60 * 60 + 3 * 60 - 13, $time->setTime('27:3', 'h:m')->subTime(13)->getSeconds());
     $this->assertSame(27 * 60 * 60 + 3 * 60 - 13 * 60, $time->setTime('27:3', 'h:m')->subTime(13, RW_Time::MINUTE)->getSeconds());
     $this->assertSame(27 * 60 * 60 + 3 * 60 - 13 * 60, $time->setTime('27:3', 'h:m')->subTime('13:00')->getSeconds());
     $this->assertSame(27 * 60 * 60 + 3 * 60 - 13 * 60 * 60, $time->setTime('27:3', 'h:m')->subTime(13, RW_Time::HOUR)->getSeconds());
     $this->assertSame(27 * 60 * 60 + 3 * 60 - 13 * 60 * 60, $time->setTime('27:3', 'h:m')->subTime('13:00:00')->getSeconds());
     $time = new RW_Time('13:27:3');
     $this->assertSame(13 * 60 * 60 + 27 * 60 + 3 - 13, $time->setTime('13:27:3')->subTime(13)->getSeconds());
     $this->assertSame(13 * 60 * 60 + 27 * 60 + 3 - 13 * 60, $time->setTime('13:27:3')->subTime(13, RW_Time::MINUTE)->getSeconds());
     $this->assertSame(13 * 60 * 60 + 27 * 60 + 3 - 13 * 60, $time->setTime('13:27:3')->subTime('13:00')->getSeconds());
     $this->assertSame(13 * 60 * 60 + 27 * 60 + 3 - 13 * 60 * 60, $time->setTime('13:27:3')->subTime(13, RW_Time::HOUR)->getSeconds());
     $this->assertSame(13 * 60 * 60 + 27 * 60 + 3 - 13 * 60 * 60, $time->setTime('13:27:3')->subTime('13:00:00')->getSeconds());
 }