-
Notifications
You must be signed in to change notification settings - Fork 2.5k
2.2RC1 BC Break: DateTimeFormatter sets blank data to today's date #4393
Comments
Are you working on a fix yet? (Don't want to duplicate effort!) |
Not sure of how complex a fix is required. The most simplistic fix is:
But, I'm unsure whether we should introduce an option for this. |
I'd argue if it was the original behavior, we should probably add a test and make the change. Check through the changelog to see what may have prompted the change in behavior, though; if it was on purpose, we should add an option. |
PR that introduced DateTimeFormatter is #3632 . Any thoughts on this @davidwindell ? |
@akrabat I clearly missed handling for empty values and agree we need to do so, I would be against returning '', instead simply return $value if it is protected function normalizeDateTime($value)
{
- if (is_int($value)) {
+ if (empty($value)) {
+ return $value;
+ } elseif (is_int($value)) {
$dateTime = new DateTime('@' . $value);
} elseif (!$value instanceof DateTime) {
$dateTime = new DateTime($value); |
Thanks @davidwindell - PR created. |
Wait wait, not |
Why? I would never want an |
|
Ooh yeah, @akrabat can you do a check for "" and |
Would people prefer |
: thumbsup |
👍 |
This fixes zendframework/zendframework#4393 and maintains BC.
This addresses the note raised in issue zendframework/zendframework#4393 after merge that zero is a valid UNIX timestamp.
Updating my project to 2.2 RC1, I find that any
Zend\Form\Element\Date
element can now no longer be empty as today's date is returned from the automatically addedDateTimeFormatter
filter...The text was updated successfully, but these errors were encountered: