From 1f2afd8d3ffeeb4a81f575bbcc4b67255437a754 Mon Sep 17 00:00:00 2001 From: ADmad Date: Tue, 22 Feb 2011 01:24:21 +0530 Subject: [PATCH] Removing deprecated function TimeHelper::relativeTime() which was simply an alias for TimeHelper::timeAgoInWords() --- cake/libs/view/helpers/time.php | 24 ++++--------------- .../cases/libs/view/helpers/time.test.php | 19 +++++---------- 2 files changed, 10 insertions(+), 33 deletions(-) diff --git a/cake/libs/view/helpers/time.php b/cake/libs/view/helpers/time.php index 6e1df2fe7..2540e32bc 100644 --- a/cake/libs/view/helpers/time.php +++ b/cake/libs/view/helpers/time.php @@ -56,7 +56,7 @@ class TimeHelper extends AppHelper { * Converts a string representing the format for the function strftime and returns a * windows safe and i18n aware format. * - * @param string $format Format with specifiers for strftime function. + * @param string $format Format with specifiers for strftime function. * Accepts the special specifier %S which mimics th modifier S for date() * @param string UNIX timestamp * @return string windows safe and date() function compatible format for strftime @@ -77,7 +77,7 @@ class TimeHelper extends AppHelper { * @return string converted element * @access private */ - function __translateSpecifier($specifier) { + private function __translateSpecifier($specifier) { switch ($specifier[1]) { case 'a': $abday = __c('abday', 5); @@ -361,7 +361,7 @@ class TimeHelper extends AppHelper { * @return boolean True if datetime string was yesterday * @access public * @link http://book.cakephp.org/view/1472/Testing-Time - * + * */ public function wasYesterday($dateString, $userOffset = null) { $date = $this->fromString($dateString, $userOffset); @@ -643,26 +643,10 @@ class TimeHelper extends AppHelper { return $relativeDate; } -/** - * Alias for timeAgoInWords - * - * @param mixed $dateTime Datetime string (strtotime-compatible) or Unix timestamp - * @param mixed $options Default format string, if timestamp is used in $dateTime, or an array of options to be passed - * on to timeAgoInWords(). - * @return string Relative time string. - * @see TimeHelper::timeAgoInWords - * @access public - * @deprecated This method alias will be removed in future versions. - * @link http://book.cakephp.org/view/1471/Formatting - */ - function relativeTime($dateTime, $options = array()) { - return $this->timeAgoInWords($dateTime, $options); - } - /** * Returns true if specified datetime was within the interval specified, else false. * - * @param mixed $timeInterval the numeric value with space then time type. + * @param mixed $timeInterval the numeric value with space then time type. * Example of valid types: 6 hours, 2 days, 1 minute. * @param mixed $dateString the datestring or unix timestamp to compare * @param int $userOffset User's offset from GMT (in hours) diff --git a/cake/tests/cases/libs/view/helpers/time.test.php b/cake/tests/cases/libs/view/helpers/time.test.php index 60f61fed2..aa2310bdf 100644 --- a/cake/tests/cases/libs/view/helpers/time.test.php +++ b/cake/tests/cases/libs/view/helpers/time.test.php @@ -84,6 +84,12 @@ class TimeHelperTest extends CakeTestCase { * @return void */ function testTimeAgoInWords() { + $result = $this->Time->timeAgoInWords('-1 week'); + $this->assertEqual($result, '1 week ago'); + + $result = $this->Time->timeAgoInWords('+1 week'); + $this->assertEqual($result, '1 week'); + $result = $this->Time->timeAgoInWords(strtotime('+4 months +2 weeks +3 days'), array('end' => '8 years'), true); $this->assertEqual($result, '4 months, 2 weeks, 3 days'); @@ -290,19 +296,6 @@ class TimeHelperTest extends CakeTestCase { $this->assertEqual($expected, $result); } -/** - * testRelative method - * - * @access public - * @return void - */ - function testRelative() { - $result = $this->Time->relativeTime('-1 week'); - $this->assertEqual($result, '1 week ago'); - $result = $this->Time->relativeTime('+1 week'); - $this->assertEqual($result, '1 week'); - } - /** * testNice method *