Browse Source

Minor optimization for DateTimeType

Jose Lorenzo Rodriguez 9 years ago
parent
commit
2d153f080c
1 changed files with 5 additions and 1 deletions
  1. 5 1
      src/Database/Type/DateTimeType.php

+ 5 - 1
src/Database/Type/DateTimeType.php

@@ -121,6 +121,10 @@ class DateTimeType extends Type
             list($value) = explode('.', $value);
         }
 
+        if ($this->_datetimeInstance === null) {
+            $this->_datetimeInstance = new $this->_className;
+        }
+
         $instance = clone $this->_datetimeInstance;
         return $instance->modify($value);
     }
@@ -251,7 +255,7 @@ class DateTimeType extends Type
             $class = $fallback;
         }
         $this->_className = $class;
-        $this->_datetimeInstance = new $this->_className;
+        $this->_datetimeInstance = null;
     }
 
     /**