Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

[DateTimeFormatter] Format DateTime values correctly #4509

Closed
wants to merge 1 commit into from

3 participants

@davidwindell

Fixes error;

Notice: Undefined variable: dateTime in ...zendframework\library\Zend\Filter\DateTimeFormatter.php on line 82

Fatal error: Call to a member function format() on a non-object in ...zendframework\library\Zend\Filter\DateTimeFormatter.php on line 82
@gregorybesson

Thanks a lot David,

Seems much better (and you have even found enough time to create the Unit test !)

I'm impressed by your velocity.

See ya

@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney Merge branch 'hotfix/4509'
Close #4509
393ba0e
@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-filter
@weierophinney weierophinney Merge pull request zendframework/zf2#4509 from davidwindell/hotfix-da…
…tetimeformatter-4506

[DateTimeFormatter] Format DateTime values correctly
1dfc1f4
@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-filter
@weierophinney weierophinney Merge branch 'hotfix/4509' 9e0a7f2
@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-filter
@weierophinney weierophinney Merge branch 'hotfix/4509' into develop 5b7067a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 20, 2013
  1. @davidwindell
This page is out of date. Refresh to see the latest.
View
6 library/Zend/Filter/DateTimeFormatter.php
@@ -74,11 +74,11 @@ protected function normalizeDateTime($value)
if ($value === '' || $value === null) {
return $value;
} elseif (is_int($value)) {
- $dateTime = new DateTime('@' . $value);
+ $value = new DateTime('@' . $value);
} elseif (!$value instanceof DateTime) {
- $dateTime = new DateTime($value);
+ $value = new DateTime($value);
}
- return $dateTime->format($this->format);
+ return $value->format($this->format);
}
}
View
9 tests/ZendTest/Filter/DateTimeFormatterTest.php
@@ -101,6 +101,15 @@ public function testFormatDateTimeFromTimestamp()
$this->assertEquals('2013-02-01T17:30:01+0000', $result);
}
+ public function testAcceptDateTimeValue()
+ {
+ date_default_timezone_set('UTC');
+
+ $filter = new DateTimeFormatter();
+ $result = $filter->filter(new DateTime('2012-01-01'));
+ $this->assertEquals('2012-01-01T00:00:00+0000', $result);
+ }
+
public function testInvalidArgumentExceptionThrownOnInvalidInput()
{
$this->setExpectedException('Zend\Filter\Exception\InvalidArgumentException');
Something went wrong with that request. Please try again.