diff --git a/core/config/schema/core.entity.schema.yml b/core/config/schema/core.entity.schema.yml index 65f22275df..4715230592 100644 --- a/core/config/schema/core.entity.schema.yml +++ b/core/config/schema/core.entity.schema.yml @@ -337,10 +337,10 @@ field.formatter.settings.timestamp_ago: label: 'Timestamp ago display format settings' mapping: future_format: - type: text + type: label label: 'Future format' past_format: - type: text + type: label label: 'Past format' granularity: type: integer diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampAgoFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampAgoFormatter.php index c846552944..55a2fb1a04 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampAgoFormatter.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampAgoFormatter.php @@ -2,7 +2,7 @@ namespace Drupal\Core\Field\Plugin\Field\FieldFormatter; -use Drupal\Component\Render\FormattableMarkup; +use Drupal\Component\Utility\SafeMarkup; use Drupal\Core\Cache\CacheableMetadata; use Drupal\Core\Datetime\DateFormatterInterface; use Drupal\Core\Field\FieldDefinitionInterface; @@ -187,13 +187,13 @@ protected function formatTimestamp($timestamp) { if ($this->request->server->get('REQUEST_TIME') > $timestamp) { $result = $this->dateFormatter->formatTimeDiffSince($timestamp, $options); $build = [ - '#markup' => new FormattableMarkup($this->getSetting('past_format'), ['@interval' => $result->getString()]), + '#markup' => SafeMarkup::format($this->getSetting('past_format'), ['@interval' => $result->getString()]), ]; } else { $result = $this->dateFormatter->formatTimeDiffUntil($timestamp, $options); $build = [ - '#markup' => new FormattableMarkup($this->getSetting('future_format'), ['@interval' => $result->getString()]), + '#markup' => SafeMarkup::format($this->getSetting('future_format'), ['@interval' => $result->getString()]), ]; } CacheableMetadata::createFromObject($result)->applyTo($build); diff --git a/core/modules/datetime/config/schema/datetime.schema.yml b/core/modules/datetime/config/schema/datetime.schema.yml index a00901160b..44783bdbef 100644 --- a/core/modules/datetime/config/schema/datetime.schema.yml +++ b/core/modules/datetime/config/schema/datetime.schema.yml @@ -55,10 +55,10 @@ field.formatter.settings.datetime_time_ago: label: 'Datetime time ago display format settings' mapping: future_format: - type: string + type: label label: 'Future format' past_format: - type: string + type: label label: 'Past format' granularity: type: integer