/** * Subtrai um tempo * * @param string|RW_Time $time Tempo a ser subtraído * @param string $part OPICIONAL caso seja passado um string e não RW_Time * @return RW_Time */ public function subTime($time, $part = null) { // Verifica se é um objeto RW_Time if (!$time instanceof RW_Time) { $time = new RW_Time($time, $part); } // Subtrai o tempo $this->_time -= $time->getSeconds(); // Retorna o RW_Time para manter a cadeia return $this; }
/** * Tests RW_Time::getSeconds() */ public function testGetSeconds() { $time = new RW_Time(61); $this->assertSame(61, $time->getSeconds()); $time = new RW_Time('27:3'); $this->assertSame(27 * 60 + 3, $time->getSeconds()); $time = new RW_Time('27:3', 'h:m'); $this->assertSame(27 * 60 * 60 + 3 * 60, $time->getSeconds()); $time = new RW_Time('13:27:3'); $this->assertSame(13 * 60 * 60 + 27 * 60 + 3, $time->getSeconds()); $time = new RW_Time(61, RW_Time::MINUTE); $this->assertSame(61 * 60, $time->getSeconds()); $time = new RW_Time(61, RW_Time::HOUR); $this->assertSame(61 * 60 * 60, $time->getSeconds()); $time = new RW_Time(13, RW_Time::MINUTE); $this->assertSame(13 * 60, $time->getSeconds()); $time = new RW_Time(13, RW_Time::HOUR); $this->assertSame(13 * 60 * 60, $time->getSeconds()); }