You are here

public function SitewideAlert::getScheduledEndDateTime in Sitewide Alert 8

Gets the end date of this Sitewide Alert.

Return value

\Drupal\Core\Datetime\DrupalDateTime|null The date when this alert is scheduled to end, null otherwise;

Overrides SitewideAlertInterface::getScheduledEndDateTime

1 call to SitewideAlert::getScheduledEndDateTime()
SitewideAlert::isScheduledToShowAt in src/Entity/SitewideAlert.php
Determines if this SitewideAlert should be shown at the given time.

File

src/Entity/SitewideAlert.php, line 437

Class

SitewideAlert
Defines the Sitewide Alert entity.

Namespace

Drupal\sitewide_alert\Entity

Code

public function getScheduledEndDateTime() : ?DrupalDateTime {
  $end_value = $this
    ->get('scheduled_date')->end_value;
  if ($end_value === NULL || is_array($end_value) && (empty($end_value['date']) || empty($end_value['time']))) {
    return NULL;
  }
  return DrupalDateTime::createFromFormat(DateTimeItemInterface::DATETIME_STORAGE_FORMAT, $end_value, DateTimeItemInterface::STORAGE_TIMEZONE);
}