You are here

public function DateArgumentWrapper::getMinDate in Calendar 8

Function to get min date.

Return value

\DateTime

File

src/DateArgumentWrapper.php, line 179

Class

DateArgumentWrapper
The DateArgumentWrapper class.

Namespace

Drupal\calendar

Code

public function getMinDate() {
  if (!$this->minDate) {
    $date = $this
      ->createDateTime();
    $granularity = $this
      ->getGranularity();
    if ($granularity == 'month') {
      $date
        ->modify("first day of this month");
    }
    elseif ($granularity == 'week') {
      $date
        ->modify('this week');
    }
    elseif ($granularity == 'year') {
      $date
        ->modify("first day of January");
    }
    $date
      ->setTime(0, 0, 0);
    $this->minDate = $date;
  }
  return $this->minDate;
}