You are here

public function DateArgumentWrapper::getMaxDate in Calendar 8

Function to get max date.

Return value

\DateTime

File

src/DateArgumentWrapper.php, line 203

Class

DateArgumentWrapper
The DateArgumentWrapper class.

Namespace

Drupal\calendar

Code

public function getMaxDate() {
  if (!$this->maxDate) {
    $date = $this
      ->createDateTime();
    $granularity = $this
      ->getGranularity();
    if ($granularity == 'month') {
      $date
        ->modify("last day of this month");
    }
    elseif ($granularity == 'week') {
      $date
        ->modify('this week +6 days');
    }
    elseif ($granularity == 'year') {
      $date
        ->modify("last day of December");
    }
    $date
      ->setTime(23, 59, 59);
    $this->maxDate = $date;
  }
  return $this->maxDate;
}