public function BillingPeriod::contains in Commerce Recurring Framework 8
Checks whether the given date/time is contained in the period.
Parameters
\Drupal\Core\Datetime\DrupalDateTime $date: The date/time.
Return value
bool TRUE if the date/time is contained in the period, FALSE otherwise.
File
- src/
BillingPeriod.php, line 88
Class
- BillingPeriod
- Represents a single billing period.
Namespace
Drupal\commerce_recurringCode
public function contains(DrupalDateTime $date) {
// Unlike DateTime, DrupalDateTime objects can't be compared directly.
$timestamp = $date
->format('U');
$starts = $this->startDate
->format('U');
$ends = $this->endDate
->format('U');
return $timestamp >= $starts && $timestamp < $ends;
}