From fe3951c34acc9b39f67de0188c6e1d397092588a Mon Sep 17 00:00:00 2001 From: stephan1827 Date: Fri, 26 Jun 2026 15:35:22 +0200 Subject: [PATCH] fix(dashboard): show all-day events correctly in calendar widget MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The CalendarWidget compared DTSTART timestamps with the current time, which caused all-day events (VALUE=DATE, stored as midnight UTC) to be excluded once the clock passed midnight — effectively hiding them all day. Additionally, all-day events were displayed with a time span like "in 10 hours" instead of a meaningful label. This fix detects all-day events by checking whether the DTSTART time component is 00:00:00 (standard VALUE=DATE) or 23:59:59 (used by some third-party providers as a compatibility signal). For these events: - Use a date-based comparison instead of a timestamp comparison so that today's all-day events are always shown. - Display "All day" as the subtitle instead of a formatted time span. Signed-off-by: Stephan Stricker Signed-off-by: stephan1827 --- lib/Dashboard/CalendarWidget.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/Dashboard/CalendarWidget.php b/lib/Dashboard/CalendarWidget.php index f3974e2b21..e12fa4f7d3 100644 --- a/lib/Dashboard/CalendarWidget.php +++ b/lib/Dashboard/CalendarWidget.php @@ -146,10 +146,20 @@ public function getItems(string $userId, ?string $since = null, int $limit = 7): 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; } @@ -159,9 +169,13 @@ public function getItems(string $userId, ?string $since = null, int $limit = 7): 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(),