-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
IntlExtension >= 3.8 throws Exception when formatDateTime is used and $timezone === null #3965
Comments
What about checking for |
To be honest from reading the comments I did not really understand if and if so how the behaviour should have beeen different for |
Hey @xabbuh |
Because setting the timezone to null (the default) will lead to a different output than setting the timezone to false, which is intended and also documented in the Twig docs:
{{ datetime|format_datetime(locale='en', timezone='Pacific/Midway') }}
{{ datetime|format_datetime(locale='en', timezone=false) }} |
Looking at the code it seems that the With that, it seems extraneous to also attempt handling the timezone again in the |
Background
The Exception occurred after I updated from 3.7 to 3.8 and the Workaround for me right now is to downgrade to 3.7.
Description
I use the fomat_datetime filter in many places in my app like this:
Before the update of "twig/intl-extra" from 3.7 to 3.8 that worked without any problems, but when i updated to 3.8 it suddenly gave me Excpetions:
That was wondering me a lot, so I looked into IntlExtension.php to look for the corresponding line:
So formatDateTime (which the twig filter uses) accepts $timezone === false, but then in line 379 createDateFormatter() is called with $formatterTimezone being false, throwing the Exception, because:
The solution would be to modify the formatDateTimeFunction:
Replacing the twig filter from timezone=false to timezone=null is NOT a valid solution, as it prevents the Exception from being thrown, BUT results in a wrong time being displayed, because the $date variable in the function is depending on $timezone and not $formatterTimezone
The text was updated successfully, but these errors were encountered: