Forward port fixes for #4294 from 1.3 to 2.x

CakeTime was broken in the same way as TimeHelper was in 1.x. Getting
1969 on invalid input can be very confusing and un-helpful.

Refs #4294
This commit is contained in:
mark_story 2014-08-20 00:25:01 +02:00
parent 07937d5a5f
commit 0400a63004
2 changed files with 9 additions and 0 deletions

View file

@ -597,6 +597,12 @@ class CakeTimeTest extends CakeTestCase {
$result = $this->Time->format('Y-m-d', null, 'never');
$this->assertEquals('never', $result);
$result = $this->Time->format('Y-m-d', '');
$this->assertSame('', $result);
$result = $this->Time->format('Y-m-d', false);
$this->assertSame('', $result);
$result = $this->Time->format('2012-01-13', '%d-%m-%Y', 'invalid');
$this->assertEquals('13-01-2012', $result);

View file

@ -1053,6 +1053,9 @@ class CakeTime {
if ($date === false && $default !== false) {
return $default;
}
if ($date === false) {
return '';
}
if (empty($format)) {
$format = '%x';
}