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
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 $data !== decode(encode($data)).
PHP 7.0.3 CLI from MacPorts.
$data = [
'myDate' => newDateTime('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 Y-m-d H:i:s O format string; the O format character doesn't add a colon between the timezone offset's hours and minutes (unlike the P format character). The regular expression in the decoder won't match the string without the colon in the timezone offset (the specific part of the regexp in question being Z|[-+]\d\d?(?::\d\d)?).
Fixing this is as simple as putting a single question mark in the decoder regexp after the offending colon, making it Z|[-+]\d\d?(?::?\d\d)?. I'd fix this and send a PR, but I won't get around to doing it today..
The text was updated successfully, but these errors were encountered:
dg
added a commit
that referenced
this issue
May 3, 2016
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
$data !== decode(encode($data))
.PHP 7.0.3 CLI from MacPorts.
The problem is that the encoder formats a DateTime using the
Y-m-d H:i:s O
format string; theO
format character doesn't add a colon between the timezone offset's hours and minutes (unlike theP
format character). The regular expression in the decoder won't match the string without the colon in the timezone offset (the specific part of the regexp in question beingZ|[-+]\d\d?(?::\d\d)?
).Fixing this is as simple as putting a single question mark in the decoder regexp after the offending colon, making it
Z|[-+]\d\d?(?::?\d\d)?
. I'd fix this and send a PR, but I won't get around to doing it today..The text was updated successfully, but these errors were encountered: