Skip to content

[Serializer] fixed DateTimeNormalizer to maintain microseconds when a different timezone required #29413

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

Merged
merged 1 commit into from
Dec 2, 2018
Merged

[Serializer] fixed DateTimeNormalizer to maintain microseconds when a different timezone required #29413

merged 1 commit into from
Dec 2, 2018

Conversation

rvitaliy
Copy link
Contributor

@rvitaliy rvitaliy commented Dec 1, 2018

Q A
Branch? 3.4 up to 4.2 for bug fixes
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #
License MIT
Doc PR none

fixed DateTimeNormalizer::normalizer() when $object is mutated internally to change timezone we lost microseconds of origina $object

$object = clone $object;
}

$object = $object->setTimezone($timezone);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mutating the original datetime is a change, but we safely clone any datetime no? https://3v4l.org/gdLh0

Copy link
Member

@nicolas-grekas nicolas-grekas Dec 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in clear, you mean the change should be just:
$object = (clone $object)->setTimezone($timezone);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nicolas-grekas i can't do it in one line because php 5.5 don't support it

@nicolas-grekas nicolas-grekas added this to the 3.4 milestone Dec 1, 2018
@nicolas-grekas
Copy link
Member

Thank you @rvitaliy.

@nicolas-grekas nicolas-grekas merged commit 2bf8a1c into symfony:3.4 Dec 2, 2018
nicolas-grekas added a commit that referenced this pull request Dec 2, 2018
…onds when a different timezone required (rvitaliy)

This PR was squashed before being merged into the 3.4 branch (closes #29413).

Discussion
----------

[Serializer] fixed DateTimeNormalizer to maintain microseconds when a different timezone required

| Q             | A
| ------------- | ---
| Branch?       | 3.4 up to 4.2 for bug fixes
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #
| License       | MIT
| Doc PR        | none

fixed `DateTimeNormalizer::normalizer()` when `$object` is mutated internally to change timezone we lost microseconds of origina `$object`

Commits
-------

2bf8a1c [Serializer] fixed DateTimeNormalizer to maintain microseconds when a different timezone required
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants