mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-25 13:26:26 +00:00
fab1a37d8e
This PR was squashed before being merged into the 3.x branch.
Discussion
----------
Fix timezone conversion on strings
When setting a default application timezone, and a display timezone:
```php
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
Commits
-------
f69531fa00 Fix timezone conversion on strings