mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2026-05-28 04:35:53 -04:00
IcingaConfigHelper: Icinga2 doesn't support 2m 30s
This commit is contained in:
parent
a5013cd052
commit
4dde0eaaf6
2 changed files with 6 additions and 10 deletions
|
|
@ -218,16 +218,11 @@ class IcingaConfigHelper
|
|||
);
|
||||
|
||||
foreach ($steps as $unit => $duration) {
|
||||
if ($seconds >= $duration) {
|
||||
$parts[] = (int) floor($seconds / $duration) . $unit;
|
||||
$seconds = $seconds % $duration;
|
||||
if ($seconds % $duration === 0) {
|
||||
return (int) floor($seconds / $duration) . $unit;
|
||||
}
|
||||
}
|
||||
|
||||
if ($seconds > 0) {
|
||||
$parts[] = $seconds . 's';
|
||||
}
|
||||
|
||||
return implode(' ', $parts);
|
||||
return $seconds . 's';
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,8 +28,9 @@ class IcingaConfigHelperTest extends BaseTestCase
|
|||
{
|
||||
$this->assertEquals(c::renderInterval(10), '10s');
|
||||
$this->assertEquals(c::renderInterval(60), '1m');
|
||||
$this->assertEquals(c::renderInterval(121), '2m 1s');
|
||||
$this->assertEquals(c::renderInterval(121), '121s');
|
||||
$this->assertEquals(c::renderInterval(3600), '1h');
|
||||
$this->assertEquals(c::renderInterval(86400), '1d');
|
||||
$this->assertEquals(c::renderInterval(86459), '1d 59s');
|
||||
$this->assertEquals(c::renderInterval(86459), '86459s');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue