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 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/DateTimeFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ public function filter($value)
*/
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);
Expand Down
9 changes: 9 additions & 0 deletions test/DateTimeFormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ public function tearDown()
date_default_timezone_set($this->defaultTimezone);
}

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

$filter = new DateTimeFormatter();
$result = $filter->filter('');
$this->assertEquals('', $result);
}

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

0 comments on commit c7fb429

Please sign in to comment.