$time_diff =
$this->
getSetting('time_diff'
);
$date_format =
$this->
getSetting('date_format'
);
$date_format =
$date_format ===
static::CUSTOM_DATE_FORMAT ?
$this->
getSetting('custom_date_format'
) :
$date_format;
if ($time_diff['enabled'
]) { $summary[] =
$this->
t('Displayed as a time difference'
);
$options =
['granularity' =>
$time_diff['granularity'
]];
$timestamp =
strtotime('1 year 1 month 1 week 1 day 1 hour 1 minute'
);
$interval =
$this->dateFormatter->
formatTimeDiffUntil($timestamp,
$options);
$display =
new FormattableMarkup($time_diff['future_format'
],
['@interval' =>
$interval]);
$summary[] =
$this->
t('Future date: %display',
['%display' =>
$display]);
$timestamp =
strtotime('-1 year -1 month -1 week -1 day -1 hour -1 minute'
);
$interval =
$this->dateFormatter->
formatTimeDiffSince($timestamp,
$options);
$display =
new FormattableMarkup($time_diff['past_format'
],
['@interval' =>
$interval]);
$summary[] =
$this->
t('Past date: %display',
['%display' =>
$display]);
if ($time_diff['refresh'
]) { $refresh_intervals =
$this->
getRefreshIntervals();
$summary[] =
$this->
t('Refresh every @interval',
['@interval' =>
$refresh_intervals[$time_diff['refresh'
]]]);
}