Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

this should cover everything

  • Loading branch information...
commit 383c10e50d36aee0bf01815fefc3af963ec0c6cb 1 parent 3366b9a
@nicholas-eden authored
Showing with 8 additions and 4 deletions.
  1. +3 −3 src/Carbon/Carbon.php
  2. +5 −1 tests/TestingAidsTest.php
View
6 src/Carbon/Carbon.php
@@ -85,7 +85,8 @@ class Carbon extends DateTime
'+',
'-',
'first',
- 'last'
+ 'last',
+ 'ago'
);
/**
@@ -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;
}
}
View
6 tests/TestingAidsTest.php
@@ -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());
Please sign in to comment.
Something went wrong with that request. Please try again.