Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Commit 72827c3

Browse files
committed
Merge branch 'feature/178' into develop
Close #178
2 parents 4a23858 + 7b053e3 commit 72827c3

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ All notable changes to this project will be documented in this file, in reverse
3535
when representing the element; this change allows developers to override the
3636
format, which was the original intention.
3737

38+
- [#178](https://github.com/zendframework/zend-form/pull/178) loosens the checks
39+
in `Zend\Form\Element\DateTime::getValue()` to check against PHP's `DateTimeInterface` (vs
40+
`DateTime`) when retrieving the value; this fixes edge cases where it was
41+
instead returning the format for `DateTimeImmutable` values.
42+
3843
## 2.10.3 - TBD
3944

4045
### Added

src/Element/DateTime.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ public function setOptions($options)
6666
/**
6767
* Retrieve the element value
6868
*
69-
* If the value is a DateTime object, and $returnFormattedValue is true
70-
* (the default), we return the string
71-
* representation using the currently registered format.
69+
* If the value is instance of DateTimeInterface, and $returnFormattedValue
70+
* is true (the default), we return the string representation using the
71+
* currently registered format.
7272
*
7373
* If $returnFormattedValue is false, the original value will be
7474
* returned, regardless of type.
@@ -79,7 +79,7 @@ public function setOptions($options)
7979
public function getValue($returnFormattedValue = true)
8080
{
8181
$value = parent::getValue();
82-
if (! $value instanceof PhpDateTime || ! $returnFormattedValue) {
82+
if (! $value instanceof DateTimeInterface || ! $returnFormattedValue) {
8383
return $value;
8484
}
8585
$format = $this->getFormat();

0 commit comments

Comments
 (0)