Skip to content

Commit

Permalink
DateTimeHelper & ColumnDateTime: fixed handling of null values
Browse files Browse the repository at this point in the history
  • Loading branch information
paveljanda committed May 27, 2019
1 parent 37e42b4 commit 6e52a5a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Column/ColumnDateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function getColumnValue(Row $row): string
/**
* Otherwise just return raw string
*/
return $value;
return (string) $value;
}
}

Expand Down
5 changes: 2 additions & 3 deletions src/Utils/DateTimeHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static function fromString($value, array $formats = []): \DateTime
}

foreach ($formats as $format) {
$date = \DateTime::createFromFormat($format, $value);
$date = \DateTime::createFromFormat($format, (string) $value);

if ($date === false) {
continue;
Expand All @@ -76,7 +76,7 @@ public static function fromString($value, array $formats = []): \DateTime
return $date;
}

$timestamp = strtotime($value);
$timestamp = strtotime((string) $value);

if ($timestamp !== false) {
$date = new \DateTime;
Expand All @@ -87,5 +87,4 @@ public static function fromString($value, array $formats = []): \DateTime

throw new DataGridDateTimeHelperException();
}

}

0 comments on commit 6e52a5a

Please sign in to comment.