You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yes, I thought that full DateTime object will be serialized, also with microseconds if they are part of the DateTime object. But maybe they should not be serialized because of some reasons in JMS serializer.
In one of my projects, I store DateTimeImmutable of an object, of an event which has occurred in the system.
If new PHP version supports microseconds it would be beneficial to me if serialized time would contain those microseconds, so it is less possible, that two events occur on the same time - with same hour, minute, second and microseconds.
If it's not a bug, please close that issue. I will refactor my tests so microseconds won't be considered if two DateTimeImmutable are equal.
According to PHP documentation, DateTime::setTime
Version | Description
7.1.0 | The microseconds parameter was added.
Steps required to reproduce the problem
Code like follows fails:
$date = new \DateTimeImmutable(null);
$serializer = SerializerBuilder::create()->build();
$json = $serializer->serialize($date, 'json');
$dateBack = $serializer->deserialize($json, \DateTimeImmutable::class, 'json');
$this->assertEquals($date, $dateBack);
Expected Result
Tests pass OK.
Actual Result
Failed asserting that two DateTime objects are equal.
--- Expected
+++ Actual
@@ @@
-2019-01-16T18:45:54.578422+0100
+2019-01-16T18:45:54.000000+0100
The text was updated successfully, but these errors were encountered: