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 conversion on strings #4546

Merged
merged 1 commit into from
Feb 7, 2025

Conversation

PrinsFrank
Copy link
Contributor

@PrinsFrank PrinsFrank commented Jan 20, 2025

When setting a default application timezone, and a display timezone:

date_default_timezone_set('UTC');
$twig->getExtension(\Twig\Extension\CoreExtension::class)->setTimezone('Europe/Paris');

Date objects get converted, but strings don't. See #4545.

For most other paths in convertDate, the dateTime object is initialized, and afterwards the timezone gets set. For strings, the timezone is passed as a constructor argument before having the timezone set again, losing its converting behaviour. This makes the convertDate method work identical for DateTime objects as strings. This different behaviour was already spotted in #3568.

Fixes #4545 #3568 #2819

@PrinsFrank
Copy link
Contributor Author

@fabpot Can I clarify anything or help with anything on this PR?

@fabpot fabpot force-pushed the fix-timezone-conversion-on-strings branch from 097cc72 to f69531f Compare February 7, 2025 21:52
@fabpot
Copy link
Contributor

fabpot commented Feb 7, 2025

Thank you @PrinsFrank.

@fabpot fabpot merged commit fab1a37 into twigphp:3.x Feb 7, 2025
1 check failed
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.

Automatic timezone conversion from date_default_timezone to CoreExtension timezone broken for strings
2 participants