Skip to content

Commit

Permalink
Fixing failing tests and making timeAgoInWords() actaully locale aware
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Aug 11, 2014
1 parent bea84ed commit 553d794
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Utility/Time.php
Expand Up @@ -72,7 +72,7 @@ class Time extends Carbon implements JsonSerializable {
* @var string
* @see \Cake\Utility\Time::timeAgoInWords()
*/
public static $wordFormat = 'd/M/YY';
public static $wordFormat = [IntlDateFormatter::SHORT, -1];

/**
* The format to use when formatting a time using `Time::timeAgoInWords()`
Expand Down
8 changes: 4 additions & 4 deletions tests/TestCase/Utility/TimeTest.php
Expand Up @@ -103,7 +103,7 @@ public static function timeAgoProvider() {
array('+1 week', '1 week'),
array('+1 week 1 day', '1 week, 1 day'),
array('+2 weeks 2 day', '2 weeks, 2 days'),
array('2007-9-24', 'on 24/9/07'),
array('2007-9-24', 'on 9/24/07'),
array('now', 'just now'),
);
}
Expand Down Expand Up @@ -198,7 +198,7 @@ public function testTimeAgoInWordsCustomStrings() {
'accuracy' => array('year' => 'year'),
'end' => '+2 months'
));
$expected = 'exactly on ' . date('j/n/y', strtotime('+4 months +2 weeks +3 days'));
$expected = 'exactly on ' . date('n/j/y', strtotime('+4 months +2 weeks +3 days'));
$this->assertEquals($expected, $result);
}

Expand Down Expand Up @@ -314,7 +314,7 @@ public function testTimeAgoInWordsNegativeValues() {

$time = new Time('-3 years -12 months');
$result = $time->timeAgoInWords();
$expected = 'on ' . $time->format('j/n/y');
$expected = 'on ' . $time->format('n/j/y');
$this->assertEquals($expected, $result);

$time = new Time('-1 month -1 week -6 days');
Expand All @@ -327,7 +327,7 @@ public function testTimeAgoInWordsNegativeValues() {
$result = $time->timeAgoInWords(
array('accuracy' => array('year' => 'year'))
);
$expected = 'on ' . $time->format('j/n/y');
$expected = 'on ' . $time->format('n/j/y');
$this->assertEquals($expected, $result);

$time = new Time('-13 months -5 days');
Expand Down

0 comments on commit 553d794

Please sign in to comment.