Epic #77562: Misbehaviors with datetime values and timezones
Extbase: Support \DateTimeInterface instead of \DateTime
Extbase supports conversion from and to \DateTime objects in several situations. But you cannot work with \DateTimeImmutable or other implementations of the \DateTimeInterface.
Extbase should support working with the interface instead of the concrete class.
[BUGFIX] Respect DateTimeImmutable in Extbase
The DateTimeConverter and DataMapper of Extbase now checks for
DateTimeInterface, and can thus handle DateTimeImmutable, otherwise
Extbase cannot handle these kinds of formats.
Tested-by: TYPO3com <email@example.com>
Reviewed-by: Benni Mack <firstname.lastname@example.org>
Tested-by: Benni Mack <email@example.com>
Reviewed-by: Georg Ringer <firstname.lastname@example.org>
Tested-by: Georg Ringer <email@example.com>
#2 Updated by Sebastian Michaelsen over 3 years ago
As far as I see this would affect the following things would need to be changed:
- Wrong: When loading a database record into a model object, the
\DateTimeobject even when the property is annotated as
- Wrong: When saving a model to the database the
\TYPO3\CMS\Extbase\Persistence\Generic\Backendresults in an exception because
\DateTimeImmutableto a timestamp.
- More or less right: The DateTimeConverter doesn't force
\DateTimebut performs duck typing (
is_callable(array($targetType, 'createFromFormat'))). But the override feature (
->overrideTimeIfSpecified()) forces the first paramter to be