Skip to content

Commit 9691519

Browse files
committed
bug symfony#31865 [Form] Fix wrong DateTime on outdated ICU library (aweelex)
This PR was merged into the 3.4 branch. Discussion ---------- [Form] Fix wrong DateTime on outdated ICU library | Q | A | | --- | --- | | Branch? | 3.4 | | Bug fix? | Yes | | New feature? | No | | BC breaks? | No | | Deprecations? | No | | Tests pass? | Yes | | Fixed tickets | --- | | License | MIT | There is a problem, when server uses outdated version of ICU (php-intl). It throws no exeption or debug message on unexisting Timezone. So sometimes you can get wrong DateTime in Forms, because Intl uses 'Etc/Unknown' (UTC+0) instead correct Timezone. And it happens very unobvious. I added `\IntlExeption` for that cases. Commits ------- a6025ab Change IntlTimeZone to DateTimeZone
2 parents 04c6c92 + a6025ab commit 9691519

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php

+2-5
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,8 @@ protected function getIntlDateFormatter($ignoreTimezone = false)
162162
{
163163
$dateFormat = $this->dateFormat;
164164
$timeFormat = $this->timeFormat;
165-
$timezone = $ignoreTimezone ? 'UTC' : $this->outputTimezone;
166-
if (class_exists('IntlTimeZone', false)) {
167-
// see https://bugs.php.net/bug.php?id=66323
168-
$timezone = \IntlTimeZone::createTimeZone($timezone);
169-
}
165+
$timezone = new \DateTimeZone($ignoreTimezone ? 'UTC' : $this->outputTimezone);
166+
170167
$calendar = $this->calendar;
171168
$pattern = $this->pattern;
172169

0 commit comments

Comments
 (0)