BUGFIX Made date fixes for MSSQLDatabase more robust in DataObject::__construct()

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@79375 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2009-06-16 23:31:12 +00:00
parent c5ef811b94
commit 5affa62e6c

View File

@ -265,13 +265,13 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
// MSSQLDatabase::date() uses datetime for the data type for "Date" and "SSDatetime" // MSSQLDatabase::date() uses datetime for the data type for "Date" and "SSDatetime"
switch($this->db($k)) { switch($this->db($k)) {
case "Date": case "Date":
$v = preg_replace('/([ap]m)$/i', ' \\1', $v); $v = preg_replace('/:[0-9][0-9][0-9]([ap]m)$/i', ' \\1', $v);
$record[$k] = date('Y-m-d', strtotime($v)); $record[$k] = date('Y-m-d', strtotime($v));
break; break;
case "Datetime": case "Datetime":
case "SSDatetime": case "SSDatetime":
$v = preg_replace('/([ap]m)$/i', ' \\1', $v); $v = preg_replace('/:[0-9][0-9][0-9]([ap]m)$/i', ' \\1', $v);
$record[$k] = date('Y-m-d H:i:s', strtotime($v)); $record[$k] = date('Y-m-d H:i:s', strtotime($v));
break; break;
} }