Skip to content
Permalink
Browse files

Fix RelativeTimeFormatter incorrectly formatting 'about a month ago'/…

…'in about a month'

Refs #8377
  • Loading branch information...
chinpei215 committed Mar 1, 2016
1 parent 9f4b920 commit c12162d8bc363fd78a3f5cb8a9c21e90baadc90b
Showing with 10 additions and 0 deletions.
  1. +2 −0 src/I18n/RelativeTimeFormatter.php
  2. +8 −0 tests/TestCase/I18n/TimeTest.php
@@ -152,6 +152,7 @@ public function timeAgoInWords(DatetimeInterface $time, array $options = [])
'hour' => __d('cake', 'about an hour ago'),
'day' => __d('cake', 'about a day ago'),
'week' => __d('cake', 'about a week ago'),
'month' => __d('cake', 'about a month ago'),
'year' => __d('cake', 'about a year ago')
];
return $relativeDate ? sprintf($options['relativeString'], $relativeDate) : $aboutAgo[$fWord];
@@ -167,6 +168,7 @@ public function timeAgoInWords(DatetimeInterface $time, array $options = [])
'hour' => __d('cake', 'in about an hour'),
'day' => __d('cake', 'in about a day'),
'week' => __d('cake', 'in about a week'),
'month' => __d('cake', 'in about a month'),
'year' => __d('cake', 'in about a year')
];
return $aboutIn[$fWord];
@@ -310,6 +310,10 @@ public function testTimeAgoInWordsAccuracy($class)
]);
$expected = 'in about a day';
$this->assertEquals($expected, $result);
$time = new $class('+20 days');
$result = $time->timeAgoInWords(['accuracy' => 'month']);
$this->assertEquals('in about a month', $result);
}
/**
@@ -390,6 +394,10 @@ public function testTimeAgoInWordsNegativeValues($class)
$time = new $class('-23 hours');
$result = $time->timeAgoInWords(['accuracy' => 'day']);
$this->assertEquals('about a day ago', $result);
$time = new $class('-20 days');
$result = $time->timeAgoInWords(['accuracy' => 'month']);
$this->assertEquals('about a month ago', $result);
}
/**

0 comments on commit c12162d

Please sign in to comment.
You can’t perform that action at this time.