More rigorous checking on empty / missing date - set to null, not blank

This commit is contained in:
Nathan Gray 2012-04-12 19:23:39 +00:00
parent 9503984a4b
commit 999fa2c422

View File

@ -316,7 +316,7 @@ class importexport_import_csv implements importexport_iface_import_record { //,
} }
} }
foreach((array)$fields['date-time'] as $name) { foreach((array)$fields['date-time'] as $name) {
if ($record[$name] && !is_numeric($record[$name])) if (isset($record[$name]) && !is_numeric($record[$name]) && strlen(trim($record[$name])) > 0)
{ {
// Need to handle format first // Need to handle format first
if($format == 1) if($format == 1)
@ -368,9 +368,14 @@ class importexport_import_csv implements importexport_iface_import_record { //,
$record[$name] = date('Y-m-d H:i:s', $record[$name]); $record[$name] = date('Y-m-d H:i:s', $record[$name]);
} }
} }
if(strlen(trim($record[$name])) == 0)
{
$record[$name] = null;
}
} }
foreach((array)$fields['date'] as $name) { foreach((array)$fields['date'] as $name) {
if ($record[$name] && !is_numeric($record[$name])) { if (isset($record[$name]) && !is_numeric($record[$name]) && strlen(trim($record[$name])) > 0)
{
// Need to handle format first // Need to handle format first
if($format == 1) if($format == 1)
{ {
@ -387,6 +392,10 @@ class importexport_import_csv implements importexport_iface_import_record { //,
$record[$name] = date('Y-m-d', $record[$name]); $record[$name] = date('Y-m-d', $record[$name]);
} }
} }
if(strlen(trim($record[$name])) == 0)
{
$record[$name] = null;
}
} }
// Some custom methods for conversion // Some custom methods for conversion