Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / datetime / src / Plugin / Field / FieldFormatter / DateTimeCustomFormatter.php
index 445b7ee70693b0ee7dba000523d93d1d01f19af9..984423d07f53d06fbbc1bc0fda52a37099e17072 100644 (file)
@@ -32,30 +32,18 @@ class DateTimeCustomFormatter extends DateTimeFormatterBase {
    * {@inheritdoc}
    */
   public function viewElements(FieldItemListInterface $items, $langcode) {
+    // @todo Evaluate removing this method in
+    // https://www.drupal.org/node/2793143 to determine if the behavior and
+    // markup in the base class implementation can be used instead.
     $elements = [];
 
     foreach ($items as $delta => $item) {
-      $output = '';
       if (!empty($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);
-        }
-        $this->setTimeZone($date);
-
-        $output = $this->formatDate($date);
+        $elements[$delta] = $this->buildDate($date);
       }
-      $elements[$delta] = [
-        '#markup' => $output,
-        '#cache' => [
-          'contexts' => [
-            'timezone',
-          ],
-        ],
-      ];
     }
 
     return $elements;