Skip to content

Commit

Permalink
Ensures timezones then validate chronology.
Browse files Browse the repository at this point in the history
  • Loading branch information
vever001 committed Feb 6, 2024
1 parent 7f22da7 commit 293b8a6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Link.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

/**
Expand Down

0 comments on commit 293b8a6

Please sign in to comment.