Merge branch 'stable-2.14' into stable-2.15

* stable-2.14:
  RelativeDateFormatter: Fix bad rounding of "1 year 12 months" to "2 year"

Change-Id: I9a59d799f4b3858dace45ac82aa03b3e318177f7
This commit is contained in:
David Pursehouse 2017-10-13 16:25:14 +09:00
commit 64db41de37
2 changed files with 4 additions and 0 deletions

View File

@ -123,6 +123,9 @@ public class RelativeDateFormatter {
}
if (months == 12) {
years++;
if (years > 1) {
yearLabel = c().years();
}
return m().years0MonthsAgo(years, yearLabel);
}
return m().yearsMonthsAgo(years, yearLabel, months, monthLabel);

View File

@ -98,6 +98,7 @@ public class RelativeDateFormatterTest {
assertFormat(410, DAY_IN_MILLIS, "1 year, 2 months ago");
assertFormat(2, YEAR_IN_MILLIS, "2 years ago");
assertFormat(1824, DAY_IN_MILLIS, "5 years ago");
assertFormat(2 * 365 - 10, DAY_IN_MILLIS, "2 years ago");
}
@Test