#95396JsonView missing support for DateTimeImmutable
Description
JsonView does “support” DateTime, because it automatically transforms it by formatting to ATOM.
The variant DateTimeImmutable is not formatted as ATOM, instead its properties will be listed. (offset and timestamp).
Controller code:
public function listAction(): void
{
if ($this->view instanceof JsonView) {
$this->view->setVariablesToRender(['publications']);
$this->view->setConfiguration(
[
'publications' => [
'_descendAll' => [
'_only' => [
'publishingDate',
],
'_descend' => [
'publishingDate' => [],
],
],
],
]
);
}
$this->view->assign('publications', $this->publicationRepository->findAll());
}
Actual:
[
{
"publishingDate": {
"offset": 0,
"timestamp": 1631119140
}
}
]
Expected:
[
{
"publishingDate": "2021-09-08T16:39:00+00:00"
}
]