Skip to content

Commit 553d794

Browse files
committed
Fixing failing tests and making timeAgoInWords() actaully locale aware
1 parent bea84ed commit 553d794

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/Utility/Time.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class Time extends Carbon implements JsonSerializable {
7272
* @var string
7373
* @see \Cake\Utility\Time::timeAgoInWords()
7474
*/
75-
public static $wordFormat = 'd/M/YY';
75+
public static $wordFormat = [IntlDateFormatter::SHORT, -1];
7676

7777
/**
7878
* The format to use when formatting a time using `Time::timeAgoInWords()`

tests/TestCase/Utility/TimeTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public static function timeAgoProvider() {
103103
array('+1 week', '1 week'),
104104
array('+1 week 1 day', '1 week, 1 day'),
105105
array('+2 weeks 2 day', '2 weeks, 2 days'),
106-
array('2007-9-24', 'on 24/9/07'),
106+
array('2007-9-24', 'on 9/24/07'),
107107
array('now', 'just now'),
108108
);
109109
}
@@ -198,7 +198,7 @@ public function testTimeAgoInWordsCustomStrings() {
198198
'accuracy' => array('year' => 'year'),
199199
'end' => '+2 months'
200200
));
201-
$expected = 'exactly on ' . date('j/n/y', strtotime('+4 months +2 weeks +3 days'));
201+
$expected = 'exactly on ' . date('n/j/y', strtotime('+4 months +2 weeks +3 days'));
202202
$this->assertEquals($expected, $result);
203203
}
204204

@@ -314,7 +314,7 @@ public function testTimeAgoInWordsNegativeValues() {
314314

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

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

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

0 commit comments

Comments
 (0)