This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/Serializer
Fabien Potencier 1ed41b549d feature #22444 [Serializer] DateTimeNormalizer: allow to provide timezone (ogizanagi)
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
-------

c10a780afb [Serializer] DateTimeNormalizer: allow to provide timezone
2017-06-14 12:25:49 -07:00
..
Annotation Merge branch '3.2' 2016-12-17 11:47:22 +01:00
DependencyInjection [FrameworkBundle][Serializer] Move SerializerPass to the Serializer 2017-01-25 13:54:53 +01:00
Encoder Merge branch '3.2' 2017-05-01 08:01:29 -07:00
Exception throw exception when extra attributes are used during an object denormalization 2016-09-22 01:36:40 +02:00
Mapping deprecate implicit string casting of mapping keys 2017-03-06 20:18:14 +01:00
NameConverter minor #21676 [Serializer] Reduce complexity of NameConverter (gadelat) 2017-02-20 09:20:53 -08:00
Normalizer [Serializer] DateTimeNormalizer: allow to provide timezone 2017-05-22 09:35:43 +02:00
Tests feature #22444 [Serializer] DateTimeNormalizer: allow to provide timezone (ogizanagi) 2017-06-14 12:25:49 -07:00
.gitignore Added missing files .gitignore 2013-07-21 14:12:18 +02:00
CHANGELOG.md [FrameworkBundle][Serializer] Move SerializerPass to the Serializer 2017-01-25 13:54:53 +01:00
composer.json [3.4] Allow 4.* deps 2017-05-24 11:02:43 +02:00
LICENSE updated LICENSE year 2017-01-02 12:30:00 -08:00
phpunit.xml.dist fail when detecting risky tests 2017-04-12 09:39:27 +02:00
README.md Updated all the README files 2016-03-04 08:12:06 +01:00
Serializer.php [master] Fix issues reported by static analyse 2017-02-28 16:38:18 +01:00
SerializerAwareInterface.php [2.3] CS And DocBlock Fixes 2014-12-22 16:58:09 +01:00
SerializerAwareTrait.php Add normalizer / denormalizer awarness 2016-02-19 11:48:56 +01:00
SerializerInterface.php @throws annotations should go after @return 2016-06-06 13:03:51 +02:00

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.

Resources