You are here

protected function ViewsDateFormatSqlField::setDateFormat in Views Date Format SQL 8.3

Sets date format from field options.

1 call to ViewsDateFormatSqlField::setDateFormat()
ViewsDateFormatSqlField::query in src/Plugin/views/field/ViewsDateFormatSqlField.php
Called to add the field to a query.

File

src/Plugin/views/field/ViewsDateFormatSqlField.php, line 112

Class

ViewsDateFormatSqlField
A field that displays entity timestamp field data. Supports grouping.

Namespace

Drupal\views_date_format_sql\Plugin\views\field

Code

protected function setDateFormat() {
  if (empty($this->options['settings']['date_format'])) {
    $this->format = '';
    $this->format_string = '';
    return;
  }
  $this->format = $this->options['settings']['date_format'];
  if ($this->format === 'custom') {
    $this->format_string = !empty($this->options['settings']['custom_date_format']) ? $this->options['settings']['custom_date_format'] : '';
  }
  else {

    /* @var DateFormat $formatter */
    $formatter = DateFormat::load($this->format);
    $this->format_string = empty($formatter) ? '' : $formatter
      ->getPattern();
  }
}