Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Intl] Unrecognized timezones throwing errors #54687

Open
Seb33300 opened this issue Apr 22, 2024 · 1 comment
Open

[Intl] Unrecognized timezones throwing errors #54687

Seb33300 opened this issue Apr 22, 2024 · 1 comment

Comments

@Seb33300
Copy link
Contributor

Seb33300 commented Apr 22, 2024

Symfony version(s) affected

7.0.6

Description

I am facing an exception when trying to render localized dates with twig for some timezones.

Looks like for some timezones, the Intl component uses different names than the PHP timezone list:
https://www.php.net/manual/en/timezones.europe.php

For example, in the PHP list, we have Europe/Kyiv but Intl needs Europe/Kiev.
Maybe related to the locale used?

And another issue with America/Ciudad_Juarez.

How to reproduce

I am setting the timezone to twig like this:

$this->twig->getExtension(CoreExtension::class)->setTimezone('Europe/Kyiv');
$this->twig->getExtension(CoreExtension::class)->setTimezone('America/Ciudad_Juarez');

For the first timezone, it looks to be a conflict in the timezone name, Intl is expecting Europe/Kiev:

use Symfony\Component\Intl\Timezones;

Timezones::exists('Europe/Kiev');   // returns true
Timezones::getName('Europe/Kiev');  // returns "Eastern European Time (Kyiv)"

Timezones::exists('Europe/Kyiv');   // returns true
Timezones::getName('Europe/Kyiv');  // throws exception

Timezones::getIds();  // contains "Europe/Kiev" only

Exception:

Couldn't read the indices [Names][Europe/Kyiv] for the locale "en" in "vendor\symfony\intl/Resources/data/timezones". The indices also couldn't be found for the fallback locale(s) "root".

For the second second issue with America/Ciudad_Juarez, I have no idea why it fails:

Timezones::exists('America/Ciudad_Juarez');   // returns true
Timezones::getName('America/Ciudad_Juarez');  // returns "Mountain Time (Ciudad Juárez)"
Timezones::getIds();  // contains "America/Ciudad_Juarez"

Exception:

An exception has been thrown during the rendering of a template ("datefmt_create: time zone id 'America/Ciudad_Juarez' extracted from ext/date DateTimeZone not recognized: U_ILLEGAL_ARGUMENT_ERROR").

Possible Solution

I am not sure how to solve this?
Intl component may automatically translate Europe/Kyiv into Europe/Kiev?

If not, Timezones::exists('Europe/Kyiv'); should return false and not true.

Additional Context

Maybe more issues with other timezones?
I did not try all of them.

@xabbuh
Copy link
Member

xabbuh commented Apr 22, 2024

It looks like this is related to the fact that timezones can have aliases which we handle in exists() but not in getName() (see #31354).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants