protected function DateRecurDefaultFormatter::formatDate in Recurring Dates Field 8
Creates a formatted date value as a string.
Parameters
object $date: A date object.
Return value
string A formatted date string using the chosen format.
Overrides DateTimeDefaultFormatter::formatDate
1 call to DateRecurDefaultFormatter::formatDate()
- DateRecurDefaultFormatter::settingsSummary in src/
Plugin/ Field/ FieldFormatter/ DateRecurDefaultFormatter.php - Returns a short summary for the current formatter settings.
File
- src/
Plugin/ Field/ FieldFormatter/ DateRecurDefaultFormatter.php, line 123
Class
- DateRecurDefaultFormatter
- Plugin implementation of the 'date_recur_default_formatter' formatter.
Namespace
Drupal\date_recur\Plugin\Field\FieldFormatterCode
protected function formatDate($date) {
if (!empty($date->_same_end_date)) {
$format_type = $this
->getSetting('same_end_date_format_type');
}
else {
if (empty($date->_dateRecurIsOccurrence)) {
$format_type = $this
->getSetting('format_type');
}
else {
$format_type = $this
->getSetting('occurrence_format_type');
}
}
$timezone = $this
->getSetting('timezone_override') ?: $date
->getTimezone()
->getName();
return $this->dateFormatter
->format($date
->getTimestamp(), $format_type, '', $timezone != '' ? $timezone : NULL);
}