Skip to content
Permalink
Browse files

Fix TimeHelper returning 1969 on invalid dates.

Instead of returning 1969, TimeHelper should return the invalid date,
and if that is missing '' should be returned.

Fixes #4294
  • Loading branch information...
markstory committed Aug 19, 2014
1 parent 4236ed2 commit 7e785066d4ec2230199b93c3412aa800f79769a9
Showing with 18 additions and 2 deletions.
  1. +4 −1 cake/libs/view/helpers/time.php
  2. +14 −1 cake/tests/cases/libs/view/helpers/time.test.php
@@ -727,9 +727,12 @@ function format($format, $date = null, $invalid = false, $userOffset = null) {
$format = $date;
return $this->i18nFormat($_time, $format, $invalid, $userOffset);
}
if ($time === false && $invalid == false) {
if ($time === false && $invalid !== false) {
return $invalid;
}
if ($time === false) {
return '';
}
return date($format, $time);
}
@@ -414,7 +414,7 @@ function testToRss() {
$yourTime = new DateTime('now', $yourTimezone);
$userOffset = $yourTimezone->getOffset($yourTime) / HOUR;
$this->assertEqual($yourTime->format('r'), $this->Time->toRss(time(), $userOffset));
}
}
}
}
@@ -435,6 +435,19 @@ function testFormat() {
$this->assertEqual($result, 'never');
}
/**
* test format() with empty values.
*
* @return void
*/
function testFormatEmpty() {
$result = $this->Time->format('Y-m-d', '');
$this->assertIdentical('', $result);
$result = $this->Time->format('Y-m-d', false);
$this->assertIdentical('', $result);
}
/**
* testOfGmt method
*

0 comments on commit 7e78506

Please sign in to comment.
You can’t perform that action at this time.