You are here

protected function DateRangeAllDayTrait::buildDate in Date all day 8

File

src/Plugin/Field/FieldFormatter/DateRangeAllDayTrait.php, line 60

Class

DateRangeAllDayTrait
A viewElements method, that respects an empty end date.

Namespace

Drupal\date_all_day\Plugin\Field\FieldFormatter

Code

protected function buildDate(DrupalDateTime $date, $all_day = FALSE) {
  $this
    ->setTimeZone($date);
  $build = [
    '#markup' => $this
      ->formatDate($date, $all_day),
    '#cache' => [
      'contexts' => [
        'timezone',
      ],
    ],
  ];
  return $build;
}