Feature #72149

Support \DateTimeInterface in Format\DateViewHelper

Added by Sebastian Michaelsen almost 4 years ago. Updated about 1 year ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Fluid
Target version:
-
Start date:
2015-12-10
Due date:
% Done:

100%

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);
            }
        }

Associated revisions

Revision 737125d6 (diff)
Added by Morton Jonuschat almost 4 years ago

[TASK] Support \DateTimeInterface in fluid Format\DateViewHelper

This patch changes the fluid DateViewHelper to check for date objects
implementing \DateTimeInterface so that \DateTime as well as
\DateTimeImmutable can be supplied as parameter.

Resolves: #72149
Releases: master
Change-Id: I3c3e2648168b283f8ec1fc35845a449c63d0b6ff
Reviewed-on: https://review.typo3.org/45218
Reviewed-by: Georg Ringer <>
Tested-by: Georg Ringer <>
Reviewed-by: Daniel Goerz <>
Tested-by: Daniel Goerz <>
Reviewed-by: Markus Klein <>
Tested-by: Markus Klein <>

History

#1 Updated by Gerrit Code Review almost 4 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/45218

#2 Updated by Morton Jonuschat almost 4 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

#3 Updated by Benni Mack about 1 year ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF