Skip to content

Commit

Permalink
Fix date only.
Browse files Browse the repository at this point in the history
  • Loading branch information
drishu committed May 17, 2021
1 parent d5f9f1c commit 32ba6a2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Drupal/Driver/Fields/Drupal8/DatetimeHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Drupal\Driver\Fields\Drupal8;

use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface;

/**
Expand All @@ -21,14 +22,14 @@ public function expand($values) {
// Get time, convert to ISO 8601 date in GMT/UTC, remove TZ offset.
$values[$key] = substr(gmdate('c', strtotime($relative)), 0, 19);
}
else {
elseif ($this->fieldInfo->getSetting('datetime_type') === 'datetime') {
// A Drupal install has a default site timezone, but nonetheless
// uses UTC for internal storage. If no timezone is specified in a date
// field value by the step author, assume the default timezone of
// the Drupal install, and therefore transform it into UTC for storage.
$date = new \DateTime($value, $siteTimezone);
$date->setTimezone($storageTimezone);
$values[$key] = $date->format('Y-m-d\TH:i:s');
$values[$key] = $date->format(DateTimeItemInterface::DATETIME_STORAGE_FORMAT);
}
}
return $values;
Expand Down

0 comments on commit 32ba6a2

Please sign in to comment.