mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-12 02:16:41 +00:00
Fix exception when timezone is false
This commit is contained in:
committed by
Fabien Potencier
parent
b46e93c725
commit
7e8f5eb1a5
@@ -372,7 +372,7 @@ final class IntlExtension extends AbstractExtension
|
||||
$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);
|
||||
|
||||
@@ -45,6 +45,20 @@ class IntlExtensionTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
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'));
|
||||
|
||||
Reference in New Issue
Block a user