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
diff --git a/gerrit-gwtui-common/src/main/java/com/google/gerrit/client/RelativeDateFormatter.java b/gerrit-gwtui-common/src/main/java/com/google/gerrit/client/RelativeDateFormatter.java index a0c4aa6..fdd6454 100644 --- a/gerrit-gwtui-common/src/main/java/com/google/gerrit/client/RelativeDateFormatter.java +++ b/gerrit-gwtui-common/src/main/java/com/google/gerrit/client/RelativeDateFormatter.java
@@ -123,6 +123,9 @@ } if (months == 12) { years++; + if (years > 1) { + yearLabel = c().years(); + } return m().years0MonthsAgo(years, yearLabel); } return m().yearsMonthsAgo(years, yearLabel, months, monthLabel);
diff --git a/gerrit-gwtui-common/src/test/java/com/google/gerrit/client/RelativeDateFormatterTest.java b/gerrit-gwtui-common/src/test/java/com/google/gerrit/client/RelativeDateFormatterTest.java index 5180410..6915ba7 100644 --- a/gerrit-gwtui-common/src/test/java/com/google/gerrit/client/RelativeDateFormatterTest.java +++ b/gerrit-gwtui-common/src/test/java/com/google/gerrit/client/RelativeDateFormatterTest.java
@@ -98,6 +98,7 @@ 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