Skip to content

Commit

Permalink
Update default timezone handling for dates in CiviEntityStorage.php (e…
Browse files Browse the repository at this point in the history
  • Loading branch information
nickperkins authored and puresyntax71 committed Jan 9, 2025
1 parent 6ad18a9 commit fa62da6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/CiviEntityStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ protected function initFieldValues(ContentEntityInterface $entity, array $values
}
else {
$datetime_format = $definition->getSetting('datetime_type') === DateTimeItem::DATETIME_TYPE_DATE ? DateTimeItemInterface::DATE_STORAGE_FORMAT : DateTimeItemInterface::DATETIME_STORAGE_FORMAT;
$default_timezone = \Drupal::config('system.date')->get('timezone.default') ?? date_default_timezone_get();
$default_timezone = $definition->getSetting('datetime_type') === DateTimeItem::DATETIME_TYPE_DATE ? DateTimeItemInterface::STORAGE_TIMEZONE : \Drupal::config('system.date')->get('timezone.default') ?? date_default_timezone_get();
$datetime_value = (new \DateTime($item[$main_property_name], new \DateTimeZone($default_timezone)))->setTimezone(new \DateTimeZone('UTC'))->format($datetime_format);
$item_values[$delta][$main_property_name] = $datetime_value;
}
Expand Down

0 comments on commit fa62da6

Please sign in to comment.