Skip to content

[Intl] Unrecognized timezones throwing errors #54687

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

Closed
Seb33300 opened this issue Apr 22, 2024 · 7 comments
Closed

[Intl] Unrecognized timezones throwing errors #54687

Seb33300 opened this issue Apr 22, 2024 · 7 comments

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).

@carsonbot
Copy link

Hey, thanks for your report!
There has not been a lot of activity here for a while. Is this bug still relevant? Have you managed to find a workaround?

@Seb33300
Copy link
Contributor Author

still relevant

@carsonbot carsonbot removed the Stalled label Oct 23, 2024
@nicolas-grekas
Copy link
Member

Up to have a look for a fix @Seb33300 or anyone else?
Keeping an issue open won't fix it magically ;)

@carsonbot
Copy link

Hey, thanks for your report!
There has not been a lot of activity here for a while. Is this bug still relevant? Have you managed to find a workaround?

@carsonbot
Copy link

Hello? This issue is about to be closed if nobody replies.

@carsonbot
Copy link

Hey,

I didn't hear anything so I'm going to close it. Feel free to comment if this is still relevant, I can always reopen!

@carsonbot carsonbot closed this as not planned Won't fix, can't repro, duplicate, stale May 22, 2025
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

4 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy