protected function DateRecurDefaultFormatter::buildDateRangeValue in Recurring Dates Field 8
2 calls to DateRecurDefaultFormatter::buildDateRangeValue()
- DateRecurDefaultFormatter::viewOccurrences in src/
Plugin/ Field/ FieldFormatter/ DateRecurDefaultFormatter.php - DateRecurDefaultFormatter::viewValue in src/
Plugin/ Field/ FieldFormatter/ DateRecurDefaultFormatter.php - Generate the output appropriate for one field item.
File
- src/
Plugin/ Field/ FieldFormatter/ DateRecurDefaultFormatter.php, line 96
Class
- DateRecurDefaultFormatter
- Plugin implementation of the 'date_recur_default_formatter' formatter.
Namespace
Drupal\date_recur\Plugin\Field\FieldFormatterCode
protected function buildDateRangeValue($start_date, $end_date, $isOccurrence = FALSE) {
// Protection. @todo: Find out why sometimes a \DateTime arrives.
if ($start_date instanceof \DateTime) {
$start_date = DrupalDateTime::createFromDateTime($start_date);
}
if ($end_date instanceof \DateTime) {
$end_date = DrupalDateTime::createFromDateTime($end_date);
}
if ($isOccurrence) {
$start_date->_dateRecurIsOccurrence = $end_date->_dateRecurIsOccurrence = TRUE;
}
if ($start_date
->format('Ymd') == $end_date
->format('Ymd')) {
$end_date->_same_end_date = TRUE;
}
if ($start_date
->format('U') !== $end_date
->format('U')) {
$element = [
'start_date' => $this
->buildDateWithIsoAttribute($start_date),
'separator' => [
'#plain_text' => ' ' . $this
->getSetting('separator') . ' ',
],
'end_date' => $this
->buildDateWithIsoAttribute($end_date),
];
}
else {
$element = $this
->buildDateWithIsoAttribute($start_date);
}
return $element;
}