X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=web%2Fcore%2Fmodules%2Fdatetime%2Fsrc%2FPlugin%2FField%2FFieldFormatter%2FDateTimeDefaultFormatter.php;fp=web%2Fcore%2Fmodules%2Fdatetime%2Fsrc%2FPlugin%2FField%2FFieldFormatter%2FDateTimeDefaultFormatter.php;h=fa6549665af569bfdb341fc059f26ee170309e45;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hp=7ddecec5511bd6747067c855e86c4d9147cab505;hpb=aea91e65e895364e460983b890e295aa5d5540a5;p=yaffs-website diff --git a/web/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php b/web/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php index 7ddecec55..fa6549665 100644 --- a/web/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php +++ b/web/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeDefaultFormatter.php @@ -3,7 +3,6 @@ namespace Drupal\datetime\Plugin\Field\FieldFormatter; use Drupal\Core\Datetime\DrupalDateTime; -use Drupal\Core\Field\FieldItemListInterface; use Drupal\Core\Form\FormStateInterface; /** @@ -28,59 +27,6 @@ class DateTimeDefaultFormatter extends DateTimeFormatterBase { ] + parent::defaultSettings(); } - /** - * {@inheritdoc} - */ - public function viewElements(FieldItemListInterface $items, $langcode) { - $elements = []; - - foreach ($items as $delta => $item) { - $output = ''; - $iso_date = ''; - - if ($item->date) { - /** @var \Drupal\Core\Datetime\DrupalDateTime $date */ - $date = $item->date; - - if ($this->getFieldSetting('datetime_type') == 'date') { - // A date without time will pick up the current time, use the default. - datetime_date_default_time($date); - } - - // Create the ISO date in Universal Time. - $iso_date = $date->format("Y-m-d\TH:i:s") . 'Z'; - - $this->setTimeZone($date); - - $output = $this->formatDate($date); - } - - // Display the date using theme datetime. - $elements[$delta] = [ - '#cache' => [ - 'contexts' => [ - 'timezone', - ], - ], - '#theme' => 'time', - '#text' => $output, - '#html' => FALSE, - '#attributes' => [ - 'datetime' => $iso_date, - ], - ]; - if (!empty($item->_attributes)) { - $elements[$delta]['#attributes'] += $item->_attributes; - // Unset field item attributes since they have been included in the - // formatter output and should not be rendered in the field template. - unset($item->_attributes); - } - } - - return $elements; - - } - /** * {@inheritdoc} */ @@ -122,7 +68,7 @@ class DateTimeDefaultFormatter extends DateTimeFormatterBase { $summary = parent::settingsSummary(); $date = new DrupalDateTime(); - $summary[] = t('Format: @display', ['@display' => $this->formatDate($date, $this->getFormatSettings())]); + $summary[] = t('Format: @display', ['@display' => $this->formatDate($date)]); return $summary; }