mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Removing deprecated function TimeHelper::relativeTime() which was simply an alias for TimeHelper::timeAgoInWords()
This commit is contained in:
parent
709ed7675b
commit
1f2afd8d3f
2 changed files with 10 additions and 33 deletions
|
@ -56,7 +56,7 @@ class TimeHelper extends AppHelper {
|
||||||
* Converts a string representing the format for the function strftime and returns a
|
* Converts a string representing the format for the function strftime and returns a
|
||||||
* windows safe and i18n aware format.
|
* 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()
|
* Accepts the special specifier %S which mimics th modifier S for date()
|
||||||
* @param string UNIX timestamp
|
* @param string UNIX timestamp
|
||||||
* @return string windows safe and date() function compatible format for strftime
|
* @return string windows safe and date() function compatible format for strftime
|
||||||
|
@ -77,7 +77,7 @@ class TimeHelper extends AppHelper {
|
||||||
* @return string converted element
|
* @return string converted element
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function __translateSpecifier($specifier) {
|
private function __translateSpecifier($specifier) {
|
||||||
switch ($specifier[1]) {
|
switch ($specifier[1]) {
|
||||||
case 'a':
|
case 'a':
|
||||||
$abday = __c('abday', 5);
|
$abday = __c('abday', 5);
|
||||||
|
@ -361,7 +361,7 @@ class TimeHelper extends AppHelper {
|
||||||
* @return boolean True if datetime string was yesterday
|
* @return boolean True if datetime string was yesterday
|
||||||
* @access public
|
* @access public
|
||||||
* @link http://book.cakephp.org/view/1472/Testing-Time
|
* @link http://book.cakephp.org/view/1472/Testing-Time
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function wasYesterday($dateString, $userOffset = null) {
|
public function wasYesterday($dateString, $userOffset = null) {
|
||||||
$date = $this->fromString($dateString, $userOffset);
|
$date = $this->fromString($dateString, $userOffset);
|
||||||
|
@ -643,26 +643,10 @@ class TimeHelper extends AppHelper {
|
||||||
return $relativeDate;
|
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.
|
* 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.
|
* Example of valid types: 6 hours, 2 days, 1 minute.
|
||||||
* @param mixed $dateString the datestring or unix timestamp to compare
|
* @param mixed $dateString the datestring or unix timestamp to compare
|
||||||
* @param int $userOffset User's offset from GMT (in hours)
|
* @param int $userOffset User's offset from GMT (in hours)
|
||||||
|
|
|
@ -84,6 +84,12 @@ class TimeHelperTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testTimeAgoInWords() {
|
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);
|
$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');
|
$this->assertEqual($result, '4 months, 2 weeks, 3 days');
|
||||||
|
|
||||||
|
@ -290,19 +296,6 @@ class TimeHelperTest extends CakeTestCase {
|
||||||
$this->assertEqual($expected, $result);
|
$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
|
* testNice method
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue