From 293b8a6c79add09b73a65ae6d3f45593939c5693 Mon Sep 17 00:00:00 2001 From: Herve Donner Date: Tue, 6 Feb 2024 01:48:38 +0100 Subject: [PATCH] Ensures timezones then validate chronology. --- src/Link.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Link.php b/src/Link.php index c253628..acf665a 100644 --- a/src/Link.php +++ b/src/Link.php @@ -48,15 +48,15 @@ public function __construct(string $title, \DateTimeInterface $from, \DateTimeIn $this->title = $title; $this->allDay = $allDay; - // Ensures from date is earlier than to date. - if ($this->from > $this->to) { - throw InvalidLink::negativeDateRange($from, $to); - } - // Ensures timezones match. if ($this->from->getTimezone()->getName() !== $this->to->getTimezone()->getName()) { $this->to->setTimezone($from->getTimezone()); } + + // Ensures from date is earlier than to date. + if ($this->from > $this->to) { + throw InvalidLink::negativeDateRange($from, $to); + } } /**