You are here

protected function AddToCalTypeBase::rfc3339Date in Add to Cal 8

Returns an array containing RFC 3339 formatted start and end dates.

Parameters

\Drupal\Core\Datetime\DrupalDateTime $start:

\Drupal\Core\Datetime\DrupalDateTime $end:

$timezone:

Return value

array

1 call to AddToCalTypeBase::rfc3339Date()
AddToCalTypeBase::extractEventDetails in src/AddToCalTypeBase.php

File

src/AddToCalTypeBase.php, line 203

Class

AddToCalTypeBase

Namespace

Drupal\addtocal

Code

protected function rfc3339Date(DrupalDateTime $start, DrupalDateTime $end, $timezone) {
  $start_timestamp = $start
    ->getTimestamp();
  $end_timestamp = $end
    ->getTimestamp();
  $start_date = gmdate(self::RF3339_FORMAT, $start_timestamp);
  $end_date = gmdate(self::RF3339_FORMAT, $end_timestamp);
  return [
    'start' => $start_date,
    'end' => $end_date,
    'both' => $start_date . '/' . $end_date,
    'local_start' => $this->dateFormatter
      ->format($start_timestamp, 'custom', self::DT_FORMAT, $timezone),
    'local_end' => $this->dateFormatter
      ->format($end_timestamp, 'custom', self::DT_FORMAT, $timezone),
  ];
}