Skip to content

Fix timezone fallback to CoreExtension in IntlExtension#3903

Merged
fabpot merged 1 commit intotwigphp:3.xfrom
keulinho:fix-timezone-fallback-to-core-extension
Nov 21, 2023
Merged

Fix timezone fallback to CoreExtension in IntlExtension#3903
fabpot merged 1 commit intotwigphp:3.xfrom
keulinho:fix-timezone-fallback-to-core-extension

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
@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