Permalink
Browse files

Handle null/true/false in datetime value handling.

  • Loading branch information...
1 parent 39d9a13 commit 5f43d315d0ccad9a02b1723fcbc33e42704d091e @markstory markstory committed Feb 23, 2014
Showing with 5 additions and 1 deletion.
  1. +2 −0 src/View/Widget/DateTime.php
  2. +3 −1 tests/TestCase/View/Widget/DateTimeTest.php
View
2 src/View/Widget/DateTime.php
@@ -189,6 +189,8 @@ protected function _deconstructDate($value, $options) {
try {
if (is_string($value)) {
$date = new \DateTime($value);
+ } elseif (is_bool($value) || $value === null) {
+ $date = new \DateTime();
} elseif (is_int($value)) {
$date = new \DateTime('@' . $value);
} elseif (is_array($value)) {
View
4 tests/TestCase/View/Widget/DateTimeTest.php
@@ -48,8 +48,10 @@ public function setUp() {
* @return array
*/
public static function invalidSelectedValuesProvider() {
- $date = new \DateTime('2014-01-20 12:30:45');
return [
+ 'null' => null,
+ 'false' => false,
+ 'true' => true,
'string' => ['Bag of poop'],
'int' => [-1],
'array' => [[

0 comments on commit 5f43d31

Please sign in to comment.