gdbots/pbj-php

Cloning messages loses milliseconds on \DateTimeType fields.

gdbrown opened this issue · 1 comments

the clone feature uses php's builtin serialize/unserialize to quickly create a new object with no references to the original.

        $this->data = unserialize(serialize($this->data));
        $this->unFreeze();

But, \DateTime objects with milliseconds will be lost as serializing a date object doesn't preserve them. e.g.

php > $v = \DateTime::createFromFormat('Y-m-d\TH:i:s.uP', '2014-12-25T12:12:00.123456+00:00');
php > echo serialize($v);
O:8:"DateTime":3:{s:4:"date";s:19:"2014-12-25 12:12:00";s:13:"timezone_type";i:1;s:8:"timezone";s:6:"+00:00";}

this has been fixed in php.