updating TimeHelper, fixes #3801

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6316 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
gwoo 2008-01-03 18:42:36 +00:00
parent 6191c58f69
commit d963a721b3
2 changed files with 6 additions and 6 deletions

View file

@ -287,9 +287,9 @@ class TimeHelper extends AppHelper {
}
if ($backwards) {
$start = abs($in_seconds - time());
$start = floor(abs($in_seconds - time()));
} else {
$start = abs(time() - $in_seconds);
$start = floor(abs(time() - $in_seconds));
}
$months = floor($start / 2638523.0769231);
@ -366,6 +366,7 @@ class TimeHelper extends AppHelper {
* @return bool
*/
function wasWithinLast($timeInterval, $date_string) {
$ret = false;
$date = $this->fromString($date_string);
$result = preg_split('/\\s/', $timeInterval);
$numInterval = $result[0];
@ -377,7 +378,6 @@ class TimeHelper extends AppHelper {
case "seconds":
case "second":
$timePeriod = $seconds;
$ret = $return;
break;
case "minutes":

View file

@ -85,16 +85,16 @@ class TimeTest extends UnitTestCase {
$this->assertEqual($result, 'on ' . date('j/n/y', strtotime('2 months, 2 days')));
$result = $this->Time->timeAgoInWords(strtotime('2 months, 2 days'), array('end' => '3 month'));
$this->assertEqual($result, '2 months, 2 days');
$this->assertPattern('/2 months/', $result);
$result = $this->Time->timeAgoInWords(strtotime('2 months, 12 days'), array('end' => '3 month'));
$this->assertEqual($result, '2 months, 1 week, 5 days');
$this->assertPattern('/2 months, 1 week/', $result);
$result = $this->Time->timeAgoInWords(strtotime('3 months, 5 days'), array('end' => '4 month'));
$this->assertEqual($result, '3 months, 4 days');
$result = $this->Time->timeAgoInWords(strtotime('2 months, 2 days'), array('end' => '3 month'));
$this->assertEqual($result, '2 months, 2 days');
$this->assertPattern('/2 months/', $result);
$result = $this->Time->timeAgoInWords(strtotime('2 months, 2 days'), array('end' => '1 month', 'format' => 'Y-m-d'));
$this->assertEqual($result, 'on ' . date('Y-m-d', strtotime('2 months, 2 days')));