You are here

protected function DateRange::validateDates in Recurring Dates Field 3.1.x

Same name and namespace in other branches
  1. 8.2 src/DateRange.php \Drupal\date_recur\DateRange::validateDates()
  2. 3.x src/DateRange.php \Drupal\date_recur\DateRange::validateDates()
  3. 3.0.x src/DateRange.php \Drupal\date_recur\DateRange::validateDates()

Validates the start and end dates.

Throws

\InvalidArgumentException When there is a problem with the start and/or end date.

3 calls to DateRange::validateDates()
DateRange::setEnd in src/DateRange.php
Set the end date.
DateRange::setStart in src/DateRange.php
Set the start date.
DateRange::__construct in src/DateRange.php
Creates a new DateRange.

File

src/DateRange.php, line 104

Class

DateRange
Defines a date range.

Namespace

Drupal\date_recur

Code

protected function validateDates() : void {

  // Normalize end date timezone.
  if ($this->start
    ->getTimezone()
    ->getName() !== $this->end
    ->getTimezone()
    ->getName()) {
    throw new \InvalidArgumentException('Provided dates must be the same timezone.');
  }
  if ($this->end < $this->start) {
    throw new \InvalidArgumentException('End date must not occur before start date.');
  }
}