#72149Support \DateTimeInterface in Format\DateViewHelper
Description
The DateViewHelper only supports DateTime objects or Unix Timestamps, but instead of checking for a concrete DateTime object it should support the DateTimeInterface. The way it is now, you can’t work with \DateTimeImmutable objects.
Relevant code:
if (!$date instanceof \DateTime) {
try {
$base = $base instanceof \DateTime ? $base->format('U') : strtotime((MathUtility::canBeInterpretedAsInteger($base) ? '@' : '') . $base);
$dateTimestamp = strtotime((MathUtility::canBeInterpretedAsInteger($date) ? '@' : '') . $date, $base);
$date = new \DateTime('@' . $dateTimestamp);
$date->setTimezone(new \DateTimeZone(date_default_timezone_get()));
} catch (\Exception $exception) {
throw new Exception('"' . $date . '" could not be parsed by \DateTime constructor: ' . $exception->getMessage(), 1241722579);
}
}