Actions
Feature #72149
closedSupport \DateTimeInterface in Format\DateViewHelper
Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Fluid
Target version:
-
Start date:
2015-12-10
Due date:
% Done:
100%
Estimated time:
PHP Version:
Tags:
Complexity:
Sprint Focus:
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); } }
Actions