From 7ab5476b079feeb2954420c3d18e65b4e7f42698 Mon Sep 17 00:00:00 2001 From: Joost de Bruijn Date: Wed, 8 May 2024 09:37:04 +0000 Subject: [PATCH] fix: dtend for full day events should be on the next day --- src/Components/Event.php | 9 ++++++++- ...ntegrationTest__it_can_create_a_full_day_event__1.txt | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Components/Event.php b/src/Components/Event.php index 9387834..bf7a450 100644 --- a/src/Components/Event.php +++ b/src/Components/Event.php @@ -127,7 +127,14 @@ public function startsAt(DateTimeInterface $starts, bool $withTime = true): Even public function endsAt(DateTimeInterface $ends, bool $withTime = true): Event { - $this->ends = DateTimeValue::create($ends, $withTime); + if ($this->isFullDay) { + // The DTEND is the non-inclusive end of the event. + $ends = $ends->modify('+1 day'); + $this->ends = DateTimeValue::create($ends, false); + } else { + $this->ends = DateTimeValue::create($ends, $withTime); + } + return $this; } diff --git a/tests/__snapshots__/IntegrationTest__it_can_create_a_full_day_event__1.txt b/tests/__snapshots__/IntegrationTest__it_can_create_a_full_day_event__1.txt index 94fdbc0..cf086b4 100644 --- a/tests/__snapshots__/IntegrationTest__it_can_create_a_full_day_event__1.txt +++ b/tests/__snapshots__/IntegrationTest__it_can_create_a_full_day_event__1.txt @@ -8,6 +8,6 @@ UID:uuid_2 DTSTAMP:20190306T150000Z SUMMARY:Laracon online DTSTART;VALUE=DATE:20190306 -DTEND;VALUE=DATE:20190306 +DTEND;VALUE=DATE:20190307 END:VEVENT END:VCALENDAR \ No newline at end of file