Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix timezone that is not properly set #246

Merged
merged 1 commit into from
Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand Down
10 changes: 10 additions & 0 deletions tests/Integration/EventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}