From a235fe4e23592bc7b98551d1fd60bec3d1fc8046 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Mon, 8 Nov 2021 13:05:21 +0100 Subject: [PATCH] ObjectInspectionDetail: Fix timestamp formatting --- .../Common/ObjectInspectionDetail.php | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/library/Icingadb/Common/ObjectInspectionDetail.php b/library/Icingadb/Common/ObjectInspectionDetail.php index 00258ea4..5aaa2a06 100644 --- a/library/Icingadb/Common/ObjectInspectionDetail.php +++ b/library/Icingadb/Common/ObjectInspectionDetail.php @@ -218,7 +218,14 @@ abstract class ObjectInspectionDetail extends BaseHtmlElement ); } - private function formatTimestamp($ts): string + /** + * Format the given timestamp + * + * @param int|float|null $ts + * + * @return EmptyState|string + */ + private function formatTimestamp($ts) { if (empty($ts)) { return new EmptyState(t('n. a.')); @@ -234,7 +241,14 @@ abstract class ObjectInspectionDetail extends BaseHtmlElement ->format('Y-m-d\TH:i:s.vP'); } - private function formatMillisecondTimestamp($ms): string + /** + * Format the given timestamp (in milliseconds) + * + * @param int|float|null $ms + * + * @return EmptyState|string + */ + private function formatMillisecondTimestamp($ms) { return $this->formatTimestamp($ms / 1000.0); } @@ -249,7 +263,7 @@ abstract class ObjectInspectionDetail extends BaseHtmlElement return Format::seconds($ms / 1000.0); } - private function formatState(int $state): string + private function formatState(int $state) { switch (true) { case $this->object instanceof Host: