Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Encoded DateTime incompatible with Decoder #29
DateTime representation in generated Neon isn't properly parsed as a DateTime-compatible string and is therefore decoded as a string instead of a DateTime instance.
This breaks stuff, as
PHP 7.0.3 CLI from MacPorts.
$data = [ 'myDate' => new DateTime('2016-06-03T19:00:00+02:00'), ]; $neon = Nette\Neon\Neon::encode($data, Nette\Neon\Neon::BLOCK); $decoded = Nette\Neon\Neon::decode($neon); // Fatal error: Call to a member function format() on a string $decoded['myDate']->format('Y-m-d H:i:s O');
The problem is that the encoder formats a DateTime using the
Fixing this is as simple as putting a single question mark in the decoder regexp after the offending colon, making it