changing numeric check in TimeHelper::wasWithinLast to remove the use of a php extension

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6761 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
DarkAngelBGE 2008-05-05 15:04:02 +00:00
parent 44fae51ce8
commit 85cd5adaf1
2 changed files with 2 additions and 2 deletions

View file

@ -431,7 +431,7 @@ class TimeHelper extends AppHelper {
*/ */
function wasWithinLast($timeInterval, $date_string) { function wasWithinLast($timeInterval, $date_string) {
$tmp = r(' ', '', $timeInterval); $tmp = r(' ', '', $timeInterval);
if (is_int($tmp) || preg_match('/[\d]+/', $tmp)) { if (is_numeric($tmp)) {
$timeInterval = $tmp.' days'; $timeInterval = $tmp.' days';
} }

View file

@ -501,7 +501,7 @@ class TimeTest extends UnitTestCase {
$this->assertTrue($this->Time->wasWithinLast('5 ', '-3 days')); $this->assertTrue($this->Time->wasWithinLast('5 ', '-3 days'));
$this->assertTrue($this->Time->wasWithinLast('1 ', '-1 hour')); $this->assertTrue($this->Time->wasWithinLast('1 ', '-1 hour'));
$this->assertTrue($this->Time->wasWithinLast('1 ', '-1 minute')); $this->assertTrue($this->Time->wasWithinLast('1 ', '-1 minute'));
$this->assertTrue($this->Time->wasWithinLast('1 ', '-23 hours -59 minutes - 59 seconds')); $this->assertTrue($this->Time->wasWithinLast('1 ', '-23 hours -59 minutes -59 seconds'));
} }
function tearDown() { function tearDown() {