You are here

public function Formatter::drupal_date_format in Forena Reports 8

Date formatting method

Parameters

string $value:

string $format_string:

Return value

bool|string

1 call to Formatter::drupal_date_format()
Formatter::iso_date in src/FrxPlugin/FieldFormatter/Formatter.php
Format an ISO date as a date.

File

src/FrxPlugin/FieldFormatter/Formatter.php, line 104
contains various methods for extending report formating, layout, transformation and design.

Class

Formatter
Formatter for common drupal fields.

Namespace

Drupal\forena\FrxPlugin\FieldFormatter

Code

public function drupal_date_format($value, $format_string) {
  if (!$format_string) {
    $format_string = 'small';
  }
  switch ($format_string) {
    case 'medium':
      $type = $format_string;
      $format = '';
      break;
    case 'small':
      $type = $format_string;
      $format = '';
      break;
    case 'large':
      $type = $format_string;
      $format = '';
      break;
    default:
      $type = 'custom';
      $format = $format_string;
  }
  if ($value) {
    if ($type != 'custom') {
      $value = \Drupal::service('date.formatter')
        ->format($value);
    }
    else {
      $value = date($format, $value);
    }
  }
  return $value;
}