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

This commit is contained in:
Ralf Becker 2012-04-13 08:27:40 +00:00
parent dc2c5e1f30
commit e8377f28cf

View File

@ -316,7 +316,7 @@ class importexport_import_csv implements importexport_iface_import_record { //,
}
}
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
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]);
}
}
if(strlen(trim($record[$name])) == 0)
{
$record[$name] = null;
}
}
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
if($format == 1)
{
@ -387,6 +392,10 @@ class importexport_import_csv implements importexport_iface_import_record { //,
$record[$name] = date('Y-m-d', $record[$name]);
}
}
if(strlen(trim($record[$name])) == 0)
{
$record[$name] = null;
}
}
// Some custom methods for conversion