Skip to content

Commit aff615a

Browse files
committed
order occurrences based on the default timezone
1 parent b14035b commit aff615a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/Tags/Events.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,19 @@ public function calendar(): Collection
4040
$month = $this->params->get('month', now()->englishMonth);
4141
$year = $this->params->get('year', now()->year);
4242

43-
$from = parse_date($month.' '.$year)->startOfMonth()->startOfWeek();
44-
$to = parse_date($month.' '.$year)->endOfMonth()->endOfWeek();
43+
$from = parse_date($month . ' ' . $year)->startOfMonth()->startOfWeek();
44+
$to = parse_date($month . ' ' . $year)->endOfMonth()->endOfWeek();
4545

4646
$occurrences = $this
4747
->generator()
4848
->between(from: $from, to: $to)
4949
->groupBy(function (Entry $occurrence) {
50-
$start = $occurrence->start->setTimezone('UTC');
51-
$end = $occurrence->end->setTimezone('UTC');
50+
$start = $occurrence->start->setTimezone($this->params->get('timezone') ?? Generator::timezone());
51+
$end = $occurrence->end->setTimezone($this->params->get('timezone') ?? Generator::timezone());
5252

5353
return $start->isSameDay($end) ? $start->toDateString() : [$start->toDateString(), $end->toDateString()];
5454
})
55-
->map(fn (EntryCollection $occurrences, string $date) => $this->day(date: $date, occurrences: $occurrences));
55+
->map(fn(EntryCollection $occurrences, string $date) => $this->day(date: $date, occurrences: $occurrences));
5656

5757
$days = $this->output($this->makeEmptyDates(from: $from, to: $to)->merge($occurrences)->values());
5858

0 commit comments

Comments
 (0)