|
11 | 11 | use RRule\RRuleInterface; |
12 | 12 | use Spatie\IcalendarGenerator\Components\Event as ICalendarEvent; |
13 | 13 | use Statamic\Entries\Entry; |
| 14 | +use TransformStudios\Events\Events; |
14 | 15 |
|
15 | 16 | abstract class Event |
16 | 17 | { |
@@ -87,14 +88,14 @@ public function startTime(): string |
87 | 88 | public function start(): CarbonImmutable |
88 | 89 | { |
89 | 90 | return CarbonImmutable::parse($this->start_date) |
90 | | - ->shiftTimezone($this->timezone['name']) |
| 91 | + ->shiftTimezone($this->timezoneName()) |
91 | 92 | ->setTimeFromTimeString($this->startTime()); |
92 | 93 | } |
93 | 94 |
|
94 | 95 | public function end(): CarbonImmutable |
95 | 96 | { |
96 | 97 | return CarbonImmutable::parse($this->start_date) |
97 | | - ->shiftTimezone($this->timezone['name']) |
| 98 | + ->shiftTimezone($this->timezoneName()) |
98 | 99 | ->setTimeFromTimeString($this->endTime()); |
99 | 100 | } |
100 | 101 |
|
@@ -165,14 +166,19 @@ protected function toCarbonImmutable(string|CarbonInterface $date): CarbonImmuta |
165 | 166 | { |
166 | 167 | $carbon = is_string($date) ? CarbonImmutable::parse($date) : $date; |
167 | 168 |
|
168 | | - return $carbon->shiftTimezone($this->timezone['name']); |
| 169 | + return $carbon->shiftTimezone($this->timezoneName()); |
| 170 | + } |
| 171 | + |
| 172 | + protected function timezoneName(): string |
| 173 | + { |
| 174 | + return Arr::get($this->timezone->data(), 'name') ?? Events::defaultTimezone(); |
169 | 175 | } |
170 | 176 |
|
171 | 177 | private function collect(array $dates): Collection |
172 | 178 | { |
173 | 179 | return collect($dates) |
174 | 180 | ->map(fn (DateTimeInterface $date) => $this->supplement( |
175 | | - date: CarbonImmutable::parse($date, $this->timezone['name']) |
| 181 | + date: CarbonImmutable::parse($date, $this->timezoneName()) |
176 | 182 | ))->filter(); |
177 | 183 | } |
178 | 184 | } |
0 commit comments