Update holidays-ical.blade.php
Some checks failed
tests / ci (push) Has been cancelled

*Past events are removed.
*Events that started earlier but are still ongoing today remain visible.
*Anything from today onward displays.
This commit is contained in:
dowjames 2025-12-27 16:24:18 -05:00 committed by Benjamin Nussbaum
parent f1a9103f0d
commit 0b2b5bf25f

View file

@ -2,36 +2,46 @@
@php @php
use Carbon\Carbon; use Carbon\Carbon;
$today = Carbon::today(config('app.timezone'));
$events = collect($data['ical'] ?? []) $events = collect($data['ical'] ?? [])
->map(function (array $event): array { ->map(function (array $event): array {
$start = null;
$end = null;
try { try {
$start = isset($event['DTSTART']) ? Carbon::parse($event['DTSTART'])->setTimezone(config('app.timezone')) : null; $start = isset($event['DTSTART'])
? Carbon::parse($event['DTSTART'])->setTimezone(config('app.timezone'))
: null;
} catch (Exception $e) { } catch (Exception $e) {
$start = null; $start = null;
} }
try { try {
$end = isset($event['DTEND']) ? Carbon::parse($event['DTEND'])->setTimezone(config('app.timezone')) : null; $end = isset($event['DTEND'])
? Carbon::parse($event['DTEND'])->setTimezone(config('app.timezone'))
: null;
} catch (Exception $e) { } catch (Exception $e) {
$end = null; $end = null;
} }
return [ return [
'summary' => $event['SUMMARY'] ?? 'Untitled event', 'summary' => $event['SUMMARY'] ?? 'Untitled event',
'location' => $event['LOCATION'] ?? null, 'location' => $event['LOCATION'] ?? '—',
'start' => $start, 'start' => $start,
'end' => $end, 'end' => $end,
]; ];
}) })
->filter(fn ($event) => $event['start']) ->filter(fn ($event) =>
$event['start'] &&
(
$event['start']->greaterThanOrEqualTo($today) ||
($event['end'] && $event['end']->greaterThanOrEqualTo($today))
)
)
->sortBy('start') ->sortBy('start')
->take($size === 'quadrant' ? 5 : 8) ->take($size === 'quadrant' ? 5 : 8)
->values(); ->values();
@endphp @endphp
<x-trmnl::view size="{{$size}}"> <x-trmnl::view size="{{$size}}">
<x-trmnl::layout class="layout--col gap--small"> <x-trmnl::layout class="layout--col gap--small">
<x-trmnl::table> <x-trmnl::table>