Commit 44d77ea7 authored by xjm's avatar xjm

Issue #2851902 by mpdonadio: Replace $date->format('U') with $date->getTimestamp()

parent f2c2531c
......@@ -100,7 +100,7 @@ public function settingsForm(array $form, FormStateInterface $form_state) {
$format_types = $this->dateFormatStorage->loadMultiple();
$options = [];
foreach ($format_types as $type => $type_info) {
$format = $this->dateFormatter->format($time->format('U'), $type);
$format = $this->dateFormatter->format($time->getTimestamp(), $type);
$options[$type] = $type_info->label() . ' (' . $format . ')';
}
......
......@@ -48,7 +48,7 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
/** @var \Drupal\Core\Datetime\DrupalDateTime $end_date */
$end_date = $item->end_date;
if ($start_date->format('U') !== $end_date->format('U')) {
if ($start_date->getTimestamp() !== $end_date->getTimestamp()) {
$elements[$delta] = [
'start_date' => $this->buildDate($start_date),
'separator' => ['#plain_text' => ' ' . $separator . ' '],
......
......@@ -49,7 +49,7 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
/** @var \Drupal\Core\Datetime\DrupalDateTime $end_date */
$end_date = $item->end_date;
if ($start_date->format('U') !== $end_date->format('U')) {
if ($start_date->getTimestamp() !== $end_date->getTimestamp()) {
$elements[$delta] = [
'start_date' => $this->buildDateWithIsoAttribute($start_date),
'separator' => ['#plain_text' => ' ' . $separator . ' '],
......
......@@ -48,7 +48,7 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
/** @var \Drupal\Core\Datetime\DrupalDateTime $end_date */
$end_date = $item->end_date;
if ($start_date->format('U') !== $end_date->format('U')) {
if ($start_date->getTimestamp() !== $end_date->getTimestamp()) {
$elements[$delta] = [
'start_date' => $this->buildDate($start_date),
'separator' => ['#plain_text' => ' ' . $separator . ' '],
......
......@@ -129,7 +129,7 @@ public function validateStartEnd(array &$element, FormStateInterface $form_state
$end_date = $element['end_value']['#value']['object'];
if ($start_date instanceof DrupalDateTime && $end_date instanceof DrupalDateTime) {
if ($start_date->format('U') !== $end_date->format('U')) {
if ($start_date->getTimestamp() !== $end_date->getTimestamp()) {
$interval = $start_date->diff($end_date);
if ($interval->invert === 1) {
$form_state->setError($element, $this->t('The @title end date cannot be before the start date', ['@title' => $element['#title']]));
......
......@@ -43,13 +43,13 @@ protected function setUp() {
'format' => $default_format,
],
'langcode' => 'en',
'created' => $created_time_en->format('U'),
'created' => $created_time_en->getTimestamp(),
]);
// Add Spanish translation to the node.
$translation = $node->addTranslation('es', ['title' => 'Node ES']);
$translation->body->value = $this->randomMachineName(32);
$translation->created->value = $created_time_es->format('U');
$translation->created->value = $created_time_es->getTimestamp();
$node->save();
// Update the index.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment