public function testNegativeOneMinute() { $readableDuration = new ReadableDuration(); $readableDuration->setValueInSeconds(60 * -1); $this->assertEquals(1, $readableDuration->getMinutes()); $this->assertFalse($readableDuration->isFuture()); }
public function test5400SecondsRoundsTo2Hours() { $roundedMethodName = $this->getRoundedUnitMethodFromMethodName(__FUNCTION__); $readableDuration = new ReadableDuration(); $readableDuration->setValueInSeconds($this->getSecondValueFromMethodName(__FUNCTION__)); $this->assertEquals($this->getExpectedValueFromMethodName(__FUNCTION__), $readableDuration->{$roundedMethodName}()); }
public function test7199SecondsReturns2HoursWithPrecision2000() { $readableDuration = new ReadableDuration(); $readableDuration->setValueInSeconds(7199); $this->assertEquals(array(array('unit' => 'hour', 'value' => 2)), $readableDuration->getInMostAppropriateUnits(2)); }
public function test4000SecondsReturns1Hour() { $readableDuration = new ReadableDuration(); $readableDuration->setValueInSeconds(4000); $this->assertEquals(array('value' => 1, 'units' => 'hour'), $readableDuration->getInMostAppropriateUnits()); }
public function testOneYearInMinutes() { $readableDuration = new ReadableDuration(); $readableDuration->setValueInSeconds(60 * 60 * 24 * 365.25); $this->assertEquals(525960, $readableDuration->getInMinutes()); }
/** * Loops through response and sums seconds to calculate hours logged. * Converts seconds to hours. * * @param $response * @return int */ private function calculateHoursLogged($response) { $totalSeconds = 0; foreach ($response['data'] as $day) { $totalSeconds += $day['grand_total']['total_seconds']; } if ($this->type != 'hours') { $obj = new ReadableDuration(); $obj->setValueInSeconds($totalSeconds); return $obj; } return (int) floor($totalSeconds / 3600); }
public function testTwoPointOneYearInYears() { $readableDuration = new ReadableDuration(); $readableDuration->setValueInSeconds(60 * 60 * 24 * 365 * 2.1); $this->assertEquals(2, $readableDuration->getInYears()); }
public function testOneYearInDays() { $readableDuration = new ReadableDuration(); $readableDuration->setValueInSeconds(60 * 60 * 24 * 365); $this->assertEquals(365, $readableDuration->getInDays()); }