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

Fix timezone fallback to CoreExtension in IntlExtension #3903

Merged

Conversation

keulinho
Copy link
Contributor

@keulinho keulinho commented Nov 3, 2023

This is probably a regression from #3844

Refer to my comment on the original MR: #3844 (comment)

@fabpot
Copy link
Contributor

fabpot commented Nov 21, 2023

Thank you @keulinho.

@fabpot fabpot merged commit 78e1cdd into twigphp:3.x Nov 21, 2023
4 of 10 checks passed
@keulinho keulinho deleted the fix-timezone-fallback-to-core-extension branch November 22, 2023 07:07
@petski
Copy link

petski commented Feb 8, 2024

This PR breaks the behavior of format_datetime with timezone set to false. Calling format_datetime with timezone to false is documented as:

If the date is already a DateTime object, and if you want to keep its current timezone, pass false as the timezone value:
{{ datetime|format_datetime(locale='en', timezone=false) }}

The exception thrown if the above feature is used:

Twig\Extra\Intl\IntlExtension::createDateFormatter(): Argument #5 ($timezone) must be of type ?DateTimeZone, false given, called in /var/www/vendor/twig/intl-extra/IntlExtension.php on line 379

@xabbuh
Copy link
Contributor

xabbuh commented Feb 8, 2024

@petski see #3965

fabpot added a commit that referenced this pull request Apr 3, 2024
This PR was squashed before being merged into the 3.x branch.

Discussion
----------

Fix exception when timezone is false

When passing `false` in the timezone param, twig returns an exception:

> An exception has been thrown during the rendering of a template ("Twig\Extra\Intl\IntlExtension::createDateFormatter(): Argument 5 ($timezone) must be of type ?DateTimeZone, bool given

Passing `false` is supported and allows to skip the timezone conversion.

Regression introduced by #3903

Commits
-------

7e8f5eb Fix exception when timezone is false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants