From 83b247b8127113574d6a574998eb02b404a25696 Mon Sep 17 00:00:00 2001 From: beberlei Date: Wed, 13 Jan 2010 18:11:34 +0000 Subject: [PATCH] DDC-179 - Use ! modifier in Date Format to reset all non-date parts to zero unix timestamp values, i.e. H:i:s => '00:00:00' always --- lib/Doctrine/DBAL/Platforms/AbstractPlatform.php | 2 +- tests/Doctrine/Tests/DBAL/Types/DateTest.php | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php index 58632c4c1..165fa9aed 100644 --- a/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php +++ b/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php @@ -1719,7 +1719,7 @@ abstract class AbstractPlatform */ public function getDateFormatString() { - return 'Y-m-d'; + return '!Y-m-d'; } /** diff --git a/tests/Doctrine/Tests/DBAL/Types/DateTest.php b/tests/Doctrine/Tests/DBAL/Types/DateTest.php index 93313bc82..9f9903a0f 100644 --- a/tests/Doctrine/Tests/DBAL/Types/DateTest.php +++ b/tests/Doctrine/Tests/DBAL/Types/DateTest.php @@ -34,4 +34,11 @@ class DateTest extends \Doctrine\Tests\DbalTestCase instanceof \DateTime ); } + + public function testDateResetsNonDatePartsToZeroUnixTimeValues() + { + $date = $this->_type->convertToPHPValue('1985-09-01', $this->_platform); + + $this->assertEquals('00:00:00', $date->format('H:i:s')); + } } \ No newline at end of file