It should be perfectly valid to try to marshal a DateTime object, this will now return the same object as there is nothing to be marshaled
@@ -85,6 +85,10 @@ class DateTimeType extends \Cake\Database\Type {
* @return \Carbon\Carbon
*/
public function marshal($value) {
+ if ($value instanceof \DateTime) {
+ return $value;
+ }
+
$class = static::$dateTimeClass;
try {
if ($value === '' || $value === null || $value === false || $value === true) {
@@ -147,6 +147,10 @@ class DateTimeTypeTest extends TestCase {
],
new Time('2014-02-14 00:00:00')
+ [
+ Time::now(),
+ Time::now()
+ ]
];
}