if (\DateTimeInterface::
class === $type) { $type = \DateTimeImmutable::
class;
} if (null !==
$dateTimeFormat) { if (false !==
$object =
$type::
createFromFormat($dateTimeFormat,
$data,
$timezone)) { return $object;
} $dateTimeErrors =
$type::
getLastErrors();
throw NotNormalizableValueException::
createForUnexpectedDataType(sprintf('Parsing datetime string "%s" using format "%s" resulted in %d errors: ',
$data,
$dateTimeFormat,
$dateTimeErrors['error_count'
])."\n".
implode("\n",
$this->
formatDateTimeErrors($dateTimeErrors['errors'
])),
$data,
[Type::BUILTIN_TYPE_STRING
],
$context['deserialization_path'
] ?? null, true
);
} $defaultDateTimeFormat =
$this->defaultContext
[self::FORMAT_KEY
] ?? null;
if (null !==
$defaultDateTimeFormat) { if (false !==
$object =
$type::
createFromFormat($defaultDateTimeFormat,
$data,
$timezone)) { return $object;
} } return new $type($data,
$timezone);
}