1ed41b549d
This PR was merged into the 3.4 branch.
Discussion
----------
[Serializer] DateTimeNormalizer: allow to provide timezone
| Q | A
| ------------- | ---
| Branch? | 3.4
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | N/A
| License | MIT
| Doc PR | N/A
My own use-case was for denormalization of a csv file provided by a third-party. The datetime format inside does not contain any timezone information, and won't change, but it's established to be UTC (or at least consistent).
So by providing the new `datetime_timezone` option, the returned instance of `\DateTime(Interface)` will properly be set with the expected timezone. (In case the format already supports the time offset, the provided timezone is ignored in favor of the one parsed by the `\DateTime` object)
Regarding normalization, the expected behavior of this feature is to consistently return the same time offset.
Commits
-------
|
||
---|---|---|
.. | ||
Annotation | ||
DependencyInjection | ||
Encoder | ||
Exception | ||
Mapping | ||
NameConverter | ||
Normalizer | ||
Tests | ||
.gitignore | ||
CHANGELOG.md | ||
composer.json | ||
LICENSE | ||
phpunit.xml.dist | ||
README.md | ||
Serializer.php | ||
SerializerAwareInterface.php | ||
SerializerAwareTrait.php | ||
SerializerInterface.php |
Serializer Component
With the Serializer component it's possible to handle serializing data structures, including object graphs, into array structures or other formats like XML and JSON. It can also handle deserializing XML and JSON back to object graphs.