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

Commit

Permalink
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/DateTimeFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function filter($value)
*/
protected function normalizeDateTime($value)
{
if (empty($value)) {
if ($value === '' || $value === null) {
return $value;
} elseif (is_int($value)) {
$dateTime = new DateTime('@' . $value);
Expand Down
16 changes: 16 additions & 0 deletions test/DateTimeFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,22 @@ public function testFormatterDoesNotFormatAnEmptyString()
$this->assertEquals('', $result);
}

public function testFormatterDoesNotFormatNull()
{
$filter = new DateTimeFormatter();
$result = $filter->filter(null);
$this->assertEquals(null, $result);
}

public function testFormatterFormatsZero()
{
date_default_timezone_set('UTC');

$filter = new DateTimeFormatter();
$result = $filter->filter(0);
$this->assertEquals('1970-01-01T00:00:00+0000', $result);
}

public function testDateTimeFormatted()
{
date_default_timezone_set('UTC');
Expand Down

0 comments on commit 4bda1f3

Please sign in to comment.