diff --git a/src/Types/RecurringEvent.php b/src/Types/RecurringEvent.php index 0aafa1b..5a19573 100644 --- a/src/Types/RecurringEvent.php +++ b/src/Types/RecurringEvent.php @@ -41,7 +41,7 @@ protected function rule(): RRuleInterface ]; if ($end = $this->end_date) { - $rule['until'] = Carbon::parse($end)->endOfDay(); + $rule['until'] = Carbon::parse($end)->shiftTimezone($this->timezone['timezone'])->endOfDay(); } return new RRule($rule); diff --git a/tests/Unit/RecurringEventsTest.php b/tests/Unit/RecurringEventsTest.php index d24fd67..46ebcba 100755 --- a/tests/Unit/RecurringEventsTest.php +++ b/tests/Unit/RecurringEventsTest.php @@ -43,4 +43,25 @@ public function canCreateRecurringEvent() // $this->assertNull($event->endDate()); // $this->assertNull($event->end()); // } + + /** @test */ + public function canShowLastOccurrenceWhenNoEndTime() + { + Carbon::setTestNow(now()->setTimeFromTimeString('10:00')); + + $recurringEntry = tap(Entry::make() + ->collection('events') + ->data([ + 'start_date' => Carbon::now()->addDays(1)->toDateString(), + 'start_time' => '22:00', + 'recurrence' => 'daily', + 'end_date' => Carbon::now()->addDays(2)->toDateString(), + 'timezone' => 'America/Chicago', + ]))->save(); + + $occurrences = Events::fromCollection(handle: 'events') + ->between(Carbon::now(), Carbon::now()->addDays(5)->endOfDay()); + + $this->assertCount(2, $occurrences); + } }