/** * Imprime um tempo * * @param string|int|RW_Time $segundos Segundos ou objeto RW_Time * @param string $format OPCIONAL Formato de saida * * @return string */ public function printTime($time, $format = null) { if (!$time instanceof RW_Time) { $time = new RW_Time($time); } return $time->toString($format); }
/** * Tests RW_Time::toString() */ public function testToString() { $time = new RW_Time(49503); // 13:45:3, $this->assertSame('13:45:03', $time->toString()); $this->assertSame('13:45:03', $time->toString('hh:mm:ss')); $this->assertSame('13:45:3', $time->toString('h:m:s')); $this->assertSame('3', $time->toString('s')); $this->assertSame('03', $time->toString('ss')); $this->assertSame('45', $time->toString('m')); $this->assertSame('13', $time->toString('h')); $this->assertSame('=> 13', $time->toString('=> h')); $this->assertSame('13:45:03', $time->toString()); $this->assertSame('13:45:03', $time->toString('Shh:mm:ss')); $this->assertSame('13:45:3', $time->toString('Sh:m:s')); $this->assertSame('3', $time->toString('Ss')); $this->assertSame('03', $time->toString('Sss')); $this->assertSame('45', $time->toString('Sm')); $this->assertSame('13', $time->toString('Sh')); $this->assertSame('=> 13', $time->toString('=> Sh')); $time = new RW_Time(-49503); // 13:45:3, $this->assertSame('-13:45:03', $time->toString()); $this->assertSame('13:45:03', $time->toString('hh:mm:ss')); $this->assertSame('13:45:3', $time->toString('h:m:s')); $this->assertSame('3', $time->toString('s')); $this->assertSame('03', $time->toString('ss')); $this->assertSame('45', $time->toString('m')); $this->assertSame('13', $time->toString('h')); $this->assertSame('=> 13', $time->toString('=> h')); $this->assertSame('-', $time->toString('S')); $this->assertSame('-13:45:03', $time->toString('Shh:mm:ss')); $this->assertSame('-13:45:3', $time->toString('Sh:m:s')); $this->assertSame('-3', $time->toString('Ss')); $this->assertSame('-03', $time->toString('Sss')); $this->assertSame('-45', $time->toString('Sm')); $this->assertSame('-13', $time->toString('Sh')); $this->assertSame('=> -13', $time->toString('=> Sh')); }