Skip to content

[Form] Intl and TimezoneType are not interchangeable #22302

Closed
@rvanlaak

Description

@rvanlaak
Q A
Bug report? yes
Feature request? yes
BC Break report? no
RFC? yes
Symfony version any

We make use of the intl extension to nicely render DateTime objects according to the active locale and timezone. The problem with this combination is that it are two different kind of PHP modules, and their datasets do not completely match.

When the diff gets calculate over the intl and datetime timezones, you expected the result to be empty, but it is not. The outcome looks like the following:

"America/Fort_Nelson",
"America/Punta_Arenas",
"Antarctica/Troll",
"Asia/Atyrau",
"Asia/Barnaul",
"Asia/Chita",
"Asia/Famagusta",
"Asia/Khandyga",
"Asia/Srednekolymsk",
"Asia/Tomsk",
"Asia/Ust-Nera",
"Asia/Yangon",
"Europe/Astrakhan",
"Europe/Busingen",
"Europe/Kirov",
"Europe/Saratov",
"Europe/Ulyanovsk",
"Pacific/Bougainville"

This can be solved by using the intersect of both datasets instead:

$intlTimezones = iterator_to_array(\IntlTimeZone::createEnumeration());
$timezoneIntersection = array_intersect($intlTimezones, \DateTimeZone::listIdentifiers());

Would it be wise to let the TimezoneType choice populater take this into account in case the intl extension is available / activated? Twig does use intl by default if I'm correct?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions