mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-31 01:34:09 +02:00
Formatter should fail for invalid data
This commit is contained in:
parent
859d964d6b
commit
a79df3943a
@ -29,6 +29,8 @@
|
||||
|
||||
namespace Icinga\Util;
|
||||
|
||||
use Icinga\Exception\ProgrammingError;
|
||||
|
||||
class Format
|
||||
{
|
||||
const STANDARD_IEC = 0;
|
||||
@ -99,6 +101,9 @@ class Format
|
||||
if (! $timestamp) {
|
||||
return '-';
|
||||
}
|
||||
if (! preg_match('~^\d+$~', $timestamp)) {
|
||||
throw new ProgrammingError(sprintf('"%s" is not a number', $timestamp));
|
||||
}
|
||||
$duration = time() - $timestamp;
|
||||
$prefix = '';
|
||||
if ($duration < 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user