You are here

public function RecurringPeriodBase::getPeriodContainingDate in Recurring Time Period 8

Gets a period object that contains the given date.

For some period plugins, such as rolling periods, this will return a period identical to that returned by getPeriodFromDate().

Parameters

\DateTimeImmutable $date: A date and time that should be contained in the period.

Return value

\Drupal\recurring_period\Datetime\Period The period value object.

Overrides RecurringPeriodInterface::getPeriodContainingDate

File

src/Plugin/RecurringPeriod/RecurringPeriodBase.php, line 160

Class

RecurringPeriodBase
Base class for recurring period plugins.

Namespace

Drupal\recurring_period\Plugin\RecurringPeriod

Code

public function getPeriodContainingDate(\DateTimeImmutable $date) {
  $start_date = $this
    ->calculateStart($date);
  $end_date = $this
    ->calculateDate($date);
  $label = $this
    ->getPeriodLabel($start_date, $end_date);
  return new Period($start_date, $end_date, $label);
}