diff --git a/date_api/date_api.module b/date_api/date_api.module index 360a0ec..06dec4b 100644 --- a/date_api/date_api.module +++ b/date_api/date_api.module @@ -677,7 +677,7 @@ class DateObject extends DateTime { // object was created using only time values, and that the date values are // artifical. if (!isset($final_date['year']) && !isset($final_date['month']) && !isset($final_date['day'])) { - $this->timeOnly = TRUE; + $this->timeOnly = TRUE; } elseif (empty($this->errors)) { // setDate() expects a valid year, month, and day. diff --git a/tests/date_api.test b/tests/date_api.test index f50020c..551845c 100644 --- a/tests/date_api.test +++ b/tests/date_api.test @@ -396,6 +396,12 @@ class DateAPITestCase extends DrupalWebTestCase { $date = new dateObject($input, $timezone, $format); $this->assertNotEqual(count($date->errors), 0, '23 abc 2012 should be an invalid date'); + // Test invalid date (i.e. '0' as date) with & without timezone gives same result. + $date = new DateObject('0000-00-00'); + $this->assertEqual($date->format('Y-m-d'), '-0001-11-30'); + + $date = new dateObject('0000-00-00', 'Europe/Berlin', 'Y-m-d'); + $this->assertEqual($date->format('Y-m-d'), '-0001-11-30'); } /**