diff --git a/library/Icinga/Data/Db/DbQuery.php b/library/Icinga/Data/Db/DbQuery.php index 25acd8905..9a36c6bef 100644 --- a/library/Icinga/Data/Db/DbQuery.php +++ b/library/Icinga/Data/Db/DbQuery.php @@ -224,17 +224,17 @@ class DbQuery extends SimpleQuery protected function valueToTimestamp($value) { - if (ctype_digit($value)) { + if (is_string($value)) { + if (ctype_digit($value)) { + $value = (int) $value; + } else { + $value = strtotime($value); + } + } elseif (! is_int($value)) { $value = (int) $value; - } elseif (is_string($value)) { - $value = strtotime($value); } - if (is_int($value)) { - $value = $this->timestampForSql($value); - } - - return $value; + return $this->timestampForSql($value); } /** diff --git a/modules/monitoring/application/views/scripts/list/eventgrid.phtml b/modules/monitoring/application/views/scripts/list/eventgrid.phtml index aafa9b6b1..8809c533e 100644 --- a/modules/monitoring/application/views/scripts/list/eventgrid.phtml +++ b/modules/monitoring/application/views/scripts/list/eventgrid.phtml @@ -58,7 +58,7 @@ foreach ($summary as $entry) { $caption = sprintf( $settings[$column]['tooltip'], $value, - $this->formatDate(strtotime($day)) + $this->formatDate(strtotime($day ?? '')) ); $linkFilter = Filter::matchAll( Filter::expression('timestamp', '<', strtotime($day . ' 23:59:59')), diff --git a/modules/monitoring/library/Monitoring/Timeline/TimeRange.php b/modules/monitoring/library/Monitoring/Timeline/TimeRange.php index 26d72505e..08c7a2c3a 100644 --- a/modules/monitoring/library/Monitoring/Timeline/TimeRange.php +++ b/modules/monitoring/library/Monitoring/Timeline/TimeRange.php @@ -119,12 +119,14 @@ class TimeRange implements Iterator /** * Return whether the given time is within this range of time * - * @param int|DateTime $time The timestamp or date and time to check + * @param string|int|DateTime $time The timestamp or date and time to check */ public function validateTime($time) { if ($time instanceof DateTime) { $dateTime = $time; + } elseif (is_string($time)) { + $dateTime = DateTime::createFromFormat('d/m/Y g:i A', $time); } else { $dateTime = new DateTime(); $dateTime->setTimestamp($time);