Removing deprecated function TimeHelper::relativeTime() which was simply an alias for TimeHelper::timeAgoInWords()

This commit is contained in:
ADmad 2011-02-22 01:24:21 +05:30
parent 709ed7675b
commit 1f2afd8d3f
2 changed files with 10 additions and 33 deletions

View file

@ -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)

View file

@ -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
*