Skip to content

Commit

Permalink
this should cover everything
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholas-eden committed Sep 7, 2013
1 parent 3366b9a commit 383c10e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/Carbon/Carbon.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ class Carbon extends DateTime
'+',
'-',
'first',
'last'
'last',
'ago'
);

/**
Expand Down Expand Up @@ -732,13 +733,12 @@ public static function hasTestNow()
/**
* Determine if there is a relative keyword in the time string, this is to
* create dates relative to now for test instances. e.g.: next tuesday
* TODO: add support for 'ago' which would typically be at the end of a phrase
*
* @return boolean true if there is a keyword, otherwise false
*/
public static function hasRelativeKeywords($time) {
foreach(self::$relativeKeywords as $keyword) {
if (stripos(trim($time), $keyword) === 0) {
if (stripos(trim($time), $keyword) !== false) {
return true;
}
}
Expand Down
6 changes: 5 additions & 1 deletion tests/TestingAidsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,13 @@ public function testParseWithTestValueSet()

public function testParseRelativeWithTestValueSet()
{
$notNow = Carbon::parse('2013-09-01');
$notNow = Carbon::parse('2013-09-01 05:15:05');
Carbon::setTestNow($notNow);

$this->assertEquals('2013-09-01 05:10:05', Carbon::parse('5 minutes ago')->toDateTimeString());

$this->assertEquals('2013-08-25 05:15:05', Carbon::parse('1 week ago')->toDateTimeString());

$this->assertEquals('2013-09-02', Carbon::parse('tomorrow')->toDateString());
$this->assertEquals('2013-08-31', Carbon::parse('yesterday')->toDateString());

Expand Down

0 comments on commit 383c10e

Please sign in to comment.