function DatexDrupalDateTime::format in Datex 8
Overrides format().
Parameters
string $format: A format string using either PHP's date().
array $settings:
- timezone: (optional) String timezone name. Defaults to the timezone of the date object.
- langcode: (optional) String two letter language code used to control the result of the format() method. Defaults to NULL.
Return value
string The formatted value of the date. Since the format may contain user input, this value should be escaped when output.
Overrides DrupalDateTime::format
File
- src/
Datex/ DatexDrupalDateTime.php, line 9
Class
Namespace
Drupal\datex\DatexCode
function format($format, $settings = []) {
// $langcode = !empty($settings['langcode']) ? $settings['langcode'] : $this->langcode;
$value = '';
try {
if (!$this
->hasErrors()) {
if (isset($settings['timezone'])) {
$tz = new \DateTimeZone($settings['timezone']);
}
else {
$tz = $this
->getTimezone();
}
$cal = datex_factory($tz, 'en');
if (!$cal) {
return parent::format($format, $settings);
}
return $cal
->setTimestamp($this
->getTimestamp())
->format($format);
}
} catch (\Exception $e) {
$this->errors[] = $e
->getMessage();
}
return $value;
}