diff --git a/extra/intl-extra/IntlExtension.php b/extra/intl-extra/IntlExtension.php index 0b33331f6a8..d932e7f7fc5 100644 --- a/extra/intl-extra/IntlExtension.php +++ b/extra/intl-extra/IntlExtension.php @@ -372,7 +372,7 @@ public function formatDateTime(Environment $env, $date, ?string $dateFormat = 'm $date = CoreExtension::dateConverter($env, $date, $timezone); $formatterTimezone = $timezone; - if (null === $formatterTimezone) { + if (null === $formatterTimezone || false === $formatterTimezone) { $formatterTimezone = $date->getTimezone(); } elseif (\is_string($formatterTimezone)) { $formatterTimezone = new \DateTimeZone($timezone); diff --git a/extra/intl-extra/Tests/IntlExtensionTest.php b/extra/intl-extra/Tests/IntlExtensionTest.php index 688a415f4d0..91aa9e84f01 100644 --- a/extra/intl-extra/Tests/IntlExtensionTest.php +++ b/extra/intl-extra/Tests/IntlExtensionTest.php @@ -45,6 +45,20 @@ public function testFormatterWithoutProtoFallsBackToCoreExtensionTimezone() ); } + public function testFormatterWithoutProtoSkipTimezoneConverter() + { + $ext = new IntlExtension(); + $env = new Environment(new ArrayLoader()); + // EET is always +2 without changes for daylight saving time + // so it has a fixed difference to UTC + $env->getExtension(CoreExtension::class)->setTimezone('EET'); + + $this->assertStringStartsWith( + 'Feb 20, 2020, 1:37:00', + $ext->formatDateTime($env, new \DateTime('2020-02-20T13:37:00+00:00', new \DateTimeZone('UTC')), 'medium', 'medium', '', false) + ); + } + public function testFormatterProto() { $dateFormatterProto = new \IntlDateFormatter('fr', \IntlDateFormatter::FULL, \IntlDateFormatter::FULL, new \DateTimeZone('Europe/Paris'));