Skip to content

Commit

Permalink
fixing the handling of null cell values for date columns. Should fix #…
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinkhill committed Apr 14, 2017
1 parent d500116 commit dfa7992
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,6 @@
- 3.1.3
- Adding JavascriptDate class that mimics the way the Javascript Date object is created. (I wanted to be able to copy and paste google's examples into addRows)

- 3.1.1 & 3.1.2
- Adding back and repairing the Symfony Bundle

Expand Down
7 changes: 5 additions & 2 deletions src/DataTables/Rows/Row.php
Expand Up @@ -101,12 +101,15 @@ public static function create(DataTable $datatable, $valueArray)
foreach ($valueArray as $index => $cellValue) {
if ((bool) preg_match('/date|datetime|timeofday/', $columnTypes[$index]) === true) {
if (StringValue::isNonEmpty($cellValue) === false &&
$cellValue instanceof Carbon === false
$cellValue instanceof Carbon === false &&
$cellValue !== null
) {
throw new InvalidDate($cellValue);
}

if ($cellValue instanceof Carbon) {
if ($cellValue === null) {
$rowData[] = new NullCell;
} else if ($cellValue instanceof Carbon) {
$rowData[] = new DateCell($cellValue);
} else {
if (isset($dateTimeFormat)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Support/JavascriptDate.php
Expand Up @@ -35,7 +35,7 @@ public function __construct()
if (isset($args[3]) === false) {
$hour = $defaults['hour'];
$minute = isset($args[4]) ? $args[4] : $defaults['minute'];
$second = isset($args[5]) ? $args[5] : $defaults['minute'];
$second = isset($args[5]) ? $args[5] : $defaults['second'];
} else {
$minute = isset($args[4]) ? $args[4] : 0;
$second = isset($args[5]) ? $args[5] : 0;
Expand Down

0 comments on commit dfa7992

Please sign in to comment.