Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions lib/Dashboard/CalendarWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,20 @@
foreach ($searchResult as $calendarEvent) {
// Find first recurrence in the future
$recurrence = null;
$isAllDay = false;
foreach ($calendarEvent['objects'] as $object) {
/** @var DateTimeImmutable $startDate */
$startDate = $object['DTSTART'][0];
if ($startDate->getTimestamp() >= $dateTime->getTimestamp()) {
$time = $startDate instanceof DateTimeImmutable ? $startDate->format('H:i:s') : '';
$isAllDay = $time === '00:00:00' || $time === '23:59:59';
if ($isAllDay) {
// All-day events have no time component; compare by calendar date
// so today's events are not excluded by a timestamp comparison
if ($startDate->format('Y-m-d') >= $dateTime->format('Y-m-d')) {
$recurrence = $object;
break;
}
} elseif ($startDate->getTimestamp() >= $dateTime->getTimestamp()) {
$recurrence = $object;
break;
}
Expand All @@ -159,12 +169,16 @@
continue;
}

$subtitle = $isAllDay
? $this->l10n->t('All day')
: $this->dateTimeFormatter->formatTimeSpan(DateTime::createFromImmutable($startDate));

$widget = new WidgetItem(
$recurrence['SUMMARY'][0] ?? 'New Event',
$this->dateTimeFormatter->formatTimeSpan(DateTime::createFromImmutable($startDate)),
$subtitle,
$this->urlGenerator->getAbsoluteURL($this->urlGenerator->linkToRoute('calendar.view.index', ['objectId' => $calendarEvent['uid']])),
$this->getCalendarDotIconUrl($calendar->getDisplayColor()),
(string)$startDate->getTimestamp(),

Check failure on line 181 in lib/Dashboard/CalendarWidget.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable32

PossiblyUndefinedVariable

lib/Dashboard/CalendarWidget.php:181:14: PossiblyUndefinedVariable: Possibly undefined variable $startDate, first seen on line 152 (see https://psalm.dev/018)

Check failure on line 181 in lib/Dashboard/CalendarWidget.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable33

PossiblyUndefinedVariable

lib/Dashboard/CalendarWidget.php:181:14: PossiblyUndefinedVariable: Possibly undefined variable $startDate, first seen on line 152 (see https://psalm.dev/018)

Check failure on line 181 in lib/Dashboard/CalendarWidget.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-stable34

PossiblyUndefinedVariable

lib/Dashboard/CalendarWidget.php:181:14: PossiblyUndefinedVariable: Possibly undefined variable $startDate, first seen on line 152 (see https://psalm.dev/018)

Check failure on line 181 in lib/Dashboard/CalendarWidget.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis dev-master

PossiblyUndefinedVariable

lib/Dashboard/CalendarWidget.php:181:14: PossiblyUndefinedVariable: Possibly undefined variable $startDate, first seen on line 152 (see https://psalm.dev/018)
);
$widgetItems[] = $widget;
}
Expand Down
Loading