From 20dca7fa17008e5d9b5a9997d6d89b4eeb0f8b7f Mon Sep 17 00:00:00 2001 From: Peter Date: Tue, 16 Apr 2024 10:46:48 +0100 Subject: [PATCH] SubmitLog : Fix date format for non event logs. --- lib/Xmds/Soap.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/Xmds/Soap.php b/lib/Xmds/Soap.php index 6da1dd7ae3..09bc3c5635 100644 --- a/lib/Xmds/Soap.php +++ b/lib/Xmds/Soap.php @@ -1772,7 +1772,7 @@ protected function doSubmitLog($serverKey, $hardwareKey, $logXml) } // Adjust the date according to the display timezone - $date = $this->adjustDisplayLogDate($date); + $date = $this->adjustDisplayLogDate($date, DateFormatHelper::getSystemFormat()); // Get the date and the message (all log types have these) foreach ($node->childNodes as $nodeElements) { @@ -3042,9 +3042,10 @@ protected function setDateFilters() * Adjust the log date according to the Display timezone. * Return current date if we fail. * @param string $date + * @param string $format * @return string */ - protected function adjustDisplayLogDate(string $date): string + protected function adjustDisplayLogDate(string $date, string $format): string { // Get the display timezone to use when adjusting log dates. $defaultTimeZone = $this->getConfig()->getSetting('defaultTimezone'); @@ -3061,13 +3062,13 @@ protected function adjustDisplayLogDate(string $date): string DateFormatHelper::getSystemFormat(), $date ); - $date = $date->format('U'); + $date = $date->format($format); } catch (\Exception $e) { // Protect against the date format being unreadable $this->getLog()->debug('Date format unreadable on log message: ' . $date); // Use now instead - $date = Carbon::now()->format('U'); + $date = Carbon::now()->format($format); } return $date; @@ -3075,7 +3076,7 @@ protected function adjustDisplayLogDate(string $date): string private function createDisplayAlert(\DomElement $alertNode) { - $date = $this->adjustDisplayLogDate($alertNode->getAttribute('date')); + $date = $this->adjustDisplayLogDate($alertNode->getAttribute('date'), 'U'); $eventType = ''; $refId = ''; $detail = '';