Merge pull request #3667 from Icinga/bugfix/undefined-offset-100-3589

Format::seconds(): handle negative values as expected
This commit is contained in:
Eric Lippmann 2019-02-26 09:59:24 +01:00 committed by GitHub
commit 57f54b0f76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -54,11 +54,13 @@ class Format
public static function seconds($value)
{
if ($value < 60) {
$absValue = abs($value);
if ($absValue < 60) {
return self::formatForUnits($value, self::$secondPrefix, self::$secondBase);
} elseif ($value < 3600) {
} elseif ($absValue < 3600) {
return sprintf('%0.2f m', $value / 60);
} elseif ($value < 86400) {
} elseif ($absValue < 86400) {
return sprintf('%0.2f h', $value / 3600);
}