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

Commit

Permalink
Merge branch 'hotfix/4509'
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed May 23, 2013
2 parents bb01088 + 1dfc1f4 commit 9e0a7f2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/DateTimeFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
9 changes: 9 additions & 0 deletions test/DateTimeFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit 9e0a7f2

Please sign in to comment.