BUGFIX: Fixed date field manipulation.

MINOR: Added sorts to TableListFieldTest

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@79327 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2009-06-16 04:03:47 +00:00
parent 02d4c34d6f
commit 4df21d29e0
2 changed files with 6 additions and 6 deletions

View File

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

View File

@ -159,6 +159,7 @@ class TableListFieldTest_Obj extends DataObject implements TestOnly {
"B" => "Varchar",
"C" => "Varchar",
);
static $default_sort = "A";
function D() {
return $this->A . '/' . $this->B . '/' . $this->C;
@ -174,6 +175,7 @@ class TableListFieldTest_CsvExport extends DataObject implements TestOnly {
"A" => "Varchar",
"B" => "Varchar"
);
static $default_sort = "A";
}
class TableListFieldTest_TestController extends Controller {