Fix multi-day events filtering in IcalResponseParser

This commit is contained in:
Takács Eszter Magdolna
2026-07-21 22:00:26 +02:00
committed by Benjamin Nussbaum
parent 44ab1131ce
commit 43b8085531
@@ -36,17 +36,21 @@ class IcalResponseParser implements ResponseParser
$this->parser->parseString($normalizedBody);
$events = $this->parser->getEvents()->sorted()->getArrayCopy();
$windowStart = now()->subDays(7);
$windowEnd = now()->addDays(30);
$now = now()->startOfDay();
$filteredEvents = array_values(array_filter($events, function (array $event) use ($windowStart, $windowEnd): bool {
$filteredEvents = array_values(array_filter($events, function (array $event) use ($now): bool {
$startDate = $this->asCarbon($event['DTSTART'] ?? null);
$endDate = $this->asCarbon($event['DTEND'] ?? null);
if (! $startDate instanceof Carbon) {
if (! $startDate instanceof Carbon || ! $endDate instanceof Carbon) {
return false;
}
return $startDate->between($windowStart, $windowEnd, true);
if ($startDate->gte($now) || $endDate->gte($now)) {
return true;
}
return false;
}));
$normalizedEvents = array_map($this->normalizeIcalEvent(...), $filteredEvents);