summaryrefslogtreecommitdiffstats
path: root/gerrit-gwtui-common
diff options
context:
space:
mode:
authorDavid Pursehouse <dpursehouse@collab.net>2017-10-13 16:25:14 +0900
committerDavid Pursehouse <dpursehouse@collab.net>2017-10-13 16:25:14 +0900
commit64db41de3721bac6134fcf18a1652f28f95e8304 (patch)
treee80af4fe5b2223c3c571e593249d29586364abf6 /gerrit-gwtui-common
parent9361c5d385b1eec916ee456a1394fd4ec5d9dca4 (diff)
parent1b596afc4d9c6263125c42b3709d0a53c94b021c (diff)
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
Diffstat (limited to 'gerrit-gwtui-common')
-rw-r--r--gerrit-gwtui-common/src/main/java/com/google/gerrit/client/RelativeDateFormatter.java3
-rw-r--r--gerrit-gwtui-common/src/test/java/com/google/gerrit/client/RelativeDateFormatterTest.java1
2 files changed, 4 insertions, 0 deletions
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 a0c4aa68eb..fdd6454095 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 @@ 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);
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 51804100af..6915ba749a 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 @@ 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