Merge pull request #4844 from Icinga/fix/timeline-and-eventgrid-4843

Fix timeline and eventgrid
This commit is contained in:
Johannes Meyer 2022-06-30 10:02:36 +02:00 committed by GitHub
commit d2e4e4b2ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 10 deletions

View File

@ -224,17 +224,17 @@ class DbQuery extends SimpleQuery
protected function valueToTimestamp($value) 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; $value = (int) $value;
} elseif (is_string($value)) {
$value = strtotime($value);
} }
if (is_int($value)) { return $this->timestampForSql($value);
$value = $this->timestampForSql($value);
}
return $value;
} }
/** /**

View File

@ -58,7 +58,7 @@ foreach ($summary as $entry) {
$caption = sprintf( $caption = sprintf(
$settings[$column]['tooltip'], $settings[$column]['tooltip'],
$value, $value,
$this->formatDate(strtotime($day)) $this->formatDate(strtotime($day ?? ''))
); );
$linkFilter = Filter::matchAll( $linkFilter = Filter::matchAll(
Filter::expression('timestamp', '<', strtotime($day . ' 23:59:59')), Filter::expression('timestamp', '<', strtotime($day . ' 23:59:59')),

View File

@ -119,12 +119,14 @@ class TimeRange implements Iterator
/** /**
* Return whether the given time is within this range of time * 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) public function validateTime($time)
{ {
if ($time instanceof DateTime) { if ($time instanceof DateTime) {
$dateTime = $time; $dateTime = $time;
} elseif (is_string($time)) {
$dateTime = DateTime::createFromFormat('d/m/Y g:i A', $time);
} else { } else {
$dateTime = new DateTime(); $dateTime = new DateTime();
$dateTime->setTimestamp($time); $dateTime->setTimestamp($time);