From c04b2594a6f885d471b5e1e082a50caa45fdcd94 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 17 Jan 2019 16:40:27 +0100 Subject: [PATCH] Format::seconds(): handle negative values as expected refs #3589 --- library/Icinga/Util/Format.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/library/Icinga/Util/Format.php b/library/Icinga/Util/Format.php index f3e682128..79839b825 100644 --- a/library/Icinga/Util/Format.php +++ b/library/Icinga/Util/Format.php @@ -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); }