protected function DurationTimeFormatter::getDisplayFormat in Duration Field 8
Generate the format that will be shown to users in the settings overview.
1 call to DurationTimeFormatter::getDisplayFormat()
- DurationTimeFormatter::settingsSummary in src/
Plugin/ Field/ FieldFormatter/ DurationTimeFormatter.php - Returns a short summary for the current formatter settings.
File
- src/
Plugin/ Field/ FieldFormatter/ DurationTimeFormatter.php, line 65
Class
- DurationTimeFormatter
- Provides a formatter for the duration field type.
Namespace
Drupal\duration_field\Plugin\Field\FieldFormatterCode
protected function getDisplayFormat() {
$granularity = $this
->getFieldSetting('granularity');
$parts = [];
if ($granularity['year'] || $granularity['month'] || $granularity['day']) {
$parts[] = 'YY-MM-DD';
}
if ($granularity['hour'] || $granularity['minute'] || $granularity['second']) {
$parts[] = 'HH:MM:SS';
}
return implode(' ', $parts);
}