class DatexDrupalDateTime in Datex 8
Hierarchy
- class \Drupal\Component\Datetime\DateTimePlus uses ToStringTrait
- class \Drupal\Core\Datetime\DrupalDateTime uses StringTranslationTrait
- class \Drupal\datex\Datex\DatexDrupalDateTime
- class \Drupal\Core\Datetime\DrupalDateTime uses StringTranslationTrait
Expanded class hierarchy of DatexDrupalDateTime
6 files declare their use of DatexDrupalDateTime
- datex.inc.php in ./
datex.inc.php - DatexDateList.php in src/
Element/ DatexDateList.php - DatexDateTime.php in src/
Element/ DatexDateTime.php - DatexDateTimeDatelistWidget.php in src/
Plugin/ Field/ FieldWidget/ DatexDateTimeDatelistWidget.php - DatexDateTimeDefaultWidget.php in src/
Plugin/ Field/ FieldWidget/ DatexDateTimeDefaultWidget.php
File
- src/
Datex/ DatexDrupalDateTime.php, line 7
Namespace
Drupal\datex\DatexView source
class DatexDrupalDateTime extends DrupalDateTime {
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;
}
function origin() : DrupalDateTime {
$me = new DrupalDateTime($this
->getTimestamp(), $this
->getTimezone(), [
'langcode' => $this->langcode,
]);
$me->formatTranslationCache = $this->formatTranslationCache;
$me->stringTranslation = $this->stringTranslation;
$me->inputTimeRaw = $this->inputTimeRaw;
$me->inputTimeAdjusted = $this->inputTimeAdjusted;
$me->inputTimeZoneRaw = $this->inputTimeZoneRaw;
$me->inputTimeZoneAdjusted = $this->inputTimeZoneAdjusted;
$me->inputFormatRaw = $this->inputFormatRaw;
$me->inputFormatAdjusted = $this->inputFormatAdjusted;
$me->langcode = $this->langcode;
$me->errors = $this->errors;
$me->dateTimeObject = $this->dateTimeObject;
$me
->setTimestamp($this
->getTimestamp());
return $me;
}
static function convert(DrupalDateTime $dateTime) : DatexDrupalDateTime {
$me = new DatexDrupalDateTime($dateTime
->getTimestamp(), $dateTime
->getTimezone(), [
'langcode' => $dateTime->langcode,
]);
$me->formatTranslationCache = $dateTime->formatTranslationCache;
$me->stringTranslation = $dateTime->stringTranslation;
$me->inputTimeRaw = $dateTime->inputTimeRaw;
$me->inputTimeAdjusted = $dateTime->inputTimeAdjusted;
$me->inputTimeZoneRaw = $dateTime->inputTimeZoneRaw;
$me->inputTimeZoneAdjusted = $dateTime->inputTimeZoneAdjusted;
$me->inputFormatRaw = $dateTime->inputFormatRaw;
$me->inputFormatAdjusted = $dateTime->inputFormatAdjusted;
$me->langcode = $dateTime->langcode;
$me->errors = $dateTime->errors;
$me->dateTimeObject = $dateTime->dateTimeObject;
$me
->setTimestamp($dateTime
->getTimestamp());
return $me;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DateTimePlus:: |
protected static | property | An array of possible date parts. | |
DateTimePlus:: |
protected | property | The DateTime object. | |
DateTimePlus:: |
protected | property | An array of errors encountered when creating this date. | |
DateTimePlus:: |
protected | property | The prepared format, if provided. | |
DateTimePlus:: |
protected | property | The value of the format passed to the constructor. | |
DateTimePlus:: |
protected | property | The prepared time, without timezone, for this date. | |
DateTimePlus:: |
protected | property | The value of the time value passed to the constructor. | |
DateTimePlus:: |
protected | property | The prepared timezone object used to construct this date. | |
DateTimePlus:: |
protected | property | The value of the timezone passed to the constructor. | |
DateTimePlus:: |
protected | property | The value of the language code passed to the constructor. | |
DateTimePlus:: |
public static | function | Creates an ISO date from an array of values. | |
DateTimePlus:: |
public static | function | Checks that arrays of date parts will create a valid date. | |
DateTimePlus:: |
public | function | Examines getLastErrors() to see what errors to report. | |
DateTimePlus:: |
public static | function | Creates a date object from an array of date parts. | |
DateTimePlus:: |
public static | function | Creates a date object from an input date object. | |
DateTimePlus:: |
public static | function | Creates a date object from an input format. | |
DateTimePlus:: |
public static | function | Creates a date object from timestamp input. | |
DateTimePlus:: |
public static | function | Pads date parts with zeros. | |
DateTimePlus:: |
public | function | Returns the difference between two DateTimePlus objects. | |
DateTimePlus:: |
constant | |||
DateTimePlus:: |
public | function | Gets error messages. | |
DateTimePlus:: |
public | function | Gets a clone of the proxied PHP \DateTime object wrapped by this class. | |
DateTimePlus:: |
public | function | Detects if there were errors in the processing of this date. | |
DateTimePlus:: |
public static | function | Creates a complete array from a possibly incomplete array of date parts. | |
DateTimePlus:: |
protected | function | Prepares the input format value. | |
DateTimePlus:: |
protected | function | Prepares the input time value. | |
DateTimePlus:: |
public | function |
Renders the timezone name. Overrides ToStringTrait:: |
|
DateTimePlus:: |
constant | A RFC7231 Compliant date. | ||
DateTimePlus:: |
public | function | Sets the default time for an object built from date-only data. | |
DateTimePlus:: |
public | function | Implements the magic __call method. | |
DateTimePlus:: |
public static | function | Implements the magic __callStatic method. | |
DateTimePlus:: |
public | function | Implements the magic __clone method. | |
DatexDrupalDateTime:: |
static | function | ||
DatexDrupalDateTime:: |
function |
Overrides format(). Overrides DrupalDateTime:: |
||
DatexDrupalDateTime:: |
function | |||
DrupalDateTime:: |
protected | property | Formatted strings translation cache. | |
DrupalDateTime:: |
protected | function |
Overrides prepareTimezone(). Overrides DateTimePlus:: |
|
DrupalDateTime:: |
public | function |
Constructs a date object. Overrides DateTimePlus:: |
|
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
ToStringTrait:: |
protected | function | For test purposes, wrap die() in an overridable method. | |
ToStringTrait:: |
public | function | Implements the magic __toString() method. |