diff --git a/src/Event.php b/src/Event.php index 200e246..5def1e0 100644 --- a/src/Event.php +++ b/src/Event.php @@ -248,12 +248,12 @@ protected function setDateProperty(string $name, CarbonInterface $date) if (in_array($name, ['start.date', 'end.date'])) { $eventDateTime->setDate($date->format('Y-m-d')); - $eventDateTime->setTimezone($date->getTimezone()); + $eventDateTime->setTimezone((string) $date->getTimezone()); } if (in_array($name, ['start.dateTime', 'end.dateTime'])) { $eventDateTime->setDateTime($date->format(DateTime::RFC3339)); - $eventDateTime->setTimezone($date->getTimezone()); + $eventDateTime->setTimezone((string) $date->getTimezone()); } if (Str::startsWith($name, 'start')) { diff --git a/tests/Integration/EventTest.php b/tests/Integration/EventTest.php index 7708ee0..ab02648 100644 --- a/tests/Integration/EventTest.php +++ b/tests/Integration/EventTest.php @@ -166,4 +166,14 @@ public function it_can_create_an_event_based_on_a_text_string_statically() $event::quickCreate('Appointment at Somewhere on April 25 10am-10:25am'); } + + /** @test */ + public function it_can_set_a_timezone_that_is_a_string() + { + $now = Carbon::now()->setTimezone('Indian/Reunion'); + + $this->event->endDateTime = $now; + + $this->assertEquals((string) $now->getTimezone(), 'Indian/Reunion'); + } }