Skip to content

Commit

Permalink
Add backwards compatibility shims
Browse files Browse the repository at this point in the history
These methods are gross, but are required for backwards compatibility
with previous implementations of TimeHelper. This behavior is now
deprecated and will be removed in the next major release.
  • Loading branch information
markstory committed Nov 6, 2015
1 parent 8deb66f commit 89ae92d
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/I18n/Time.php
Expand Up @@ -433,4 +433,44 @@ public static function listTimezones($filter = null, $country = null, $options =
}
return array_combine($identifiers, $identifiers);
}

/**
* Returns true this instance will happen within the specified interval
*
* This overridden method provides backwards compatible behavior for integers,
* or strings with trailing spaces. This behavior is *deprecated* and will be
* removed in future versions of CakePHP.
*
* @param string|int $timeInterval the numeric value with space then time type.
* Example of valid types: 6 hours, 2 days, 1 minute.
* @return bool
*/
public function wasWithinLast($timeInterval)
{
$tmp = trim($timeInterval);
if (is_numeric($tmp)) {
$timeInterval = $tmp . ' days';
}
return parent::wasWithinLast($timeInterval);
}

/**
* Returns true this instance happened within the specified interval
*
* This overridden method provides backwards compatible behavior for integers,
* or strings with trailing spaces. This behavior is *deprecated* and will be
* removed in future versions of CakePHP.
*
* @param string|int $timeInterval the numeric value with space then time type.
* Example of valid types: 6 hours, 2 days, 1 minute.
* @return bool
*/
public function isWithinNext($timeInterval)
{
$tmp = trim($timeInterval);
if (is_numeric($tmp)) {
$timeInterval = $tmp . ' days';
}
return parent::isWithinNext($timeInterval);
}
}

0 comments on commit 89ae92d

Please sign in to comment.