Skip to content

Commit

Permalink
Merge pull request #6408 from cakephp/master-time
Browse files Browse the repository at this point in the history
Add fix and tests for #6402
  • Loading branch information
markstory committed Apr 24, 2015
2 parents f0f88bf + 41935cf commit d33c5e1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Database/Type/DateTimeType.php
Expand Up @@ -103,7 +103,7 @@ public function toDatabase($value, Driver $driver)
*/
public function toPHP($value, Driver $driver)
{
if ($value === null || (int)$value === 0) {
if ($value === null || strpos($value, '0000-00-00') === 0) {
return null;
}

Expand Down
6 changes: 6 additions & 0 deletions tests/TestCase/Database/Type/TimeTypeTest.php
Expand Up @@ -46,6 +46,12 @@ public function testToPHP()
{
$this->assertNull($this->type->toPHP(null, $this->driver));

$result = $this->type->toPHP('00:00:00', $this->driver);
$this->assertEquals('00', $result->format('s'));

$result = $this->type->toPHP('00:00:15', $this->driver);
$this->assertEquals('15', $result->format('s'));

$result = $this->type->toPHP('16:30:15', $this->driver);
$this->assertInstanceOf('DateTime', $result);
$this->assertEquals('16', $result->format('H'));
Expand Down

0 comments on commit d33c5e1

Please sign in to comment.