Do not use plural form for 1 second/minute/hour/day/month/year
Bug: issue 2150 Change-Id: I016484916b54789edace67cf3ed17f21580ef2c3 Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
@@ -51,32 +51,62 @@ public class RelativeDateFormatter {
|
|||||||
|
|
||||||
// seconds
|
// seconds
|
||||||
if (ageMillis < upperLimit(MINUTE_IN_MILLIS)) {
|
if (ageMillis < upperLimit(MINUTE_IN_MILLIS)) {
|
||||||
return Util.M.secondsAgo(round(ageMillis, SECOND_IN_MILLIS));
|
long seconds = round(ageMillis, SECOND_IN_MILLIS);
|
||||||
|
if (seconds == 1) {
|
||||||
|
return Util.C.oneSecondAgo();
|
||||||
|
} else {
|
||||||
|
return Util.M.secondsAgo(seconds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// minutes
|
// minutes
|
||||||
if (ageMillis < upperLimit(HOUR_IN_MILLIS)) {
|
if (ageMillis < upperLimit(HOUR_IN_MILLIS)) {
|
||||||
return Util.M.minutesAgo(round(ageMillis, MINUTE_IN_MILLIS));
|
long minutes = round(ageMillis, MINUTE_IN_MILLIS);
|
||||||
|
if (minutes == 1) {
|
||||||
|
return Util.C.oneMinuteAgo();
|
||||||
|
} else {
|
||||||
|
return Util.M.minutesAgo(minutes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// hours
|
// hours
|
||||||
if (ageMillis < upperLimit(DAY_IN_MILLIS)) {
|
if (ageMillis < upperLimit(DAY_IN_MILLIS)) {
|
||||||
return Util.M.hoursAgo(round(ageMillis, HOUR_IN_MILLIS));
|
long hours = round(ageMillis, HOUR_IN_MILLIS);
|
||||||
|
if (hours == 1) {
|
||||||
|
return Util.C.oneHourAgo();
|
||||||
|
} else {
|
||||||
|
return Util.M.hoursAgo(hours);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// up to 14 days use days
|
// up to 14 days use days
|
||||||
if (ageMillis < 14 * DAY_IN_MILLIS) {
|
if (ageMillis < 14 * DAY_IN_MILLIS) {
|
||||||
return Util.M.daysAgo(round(ageMillis, DAY_IN_MILLIS));
|
long days = round(ageMillis, DAY_IN_MILLIS);
|
||||||
|
if (days == 1) {
|
||||||
|
return Util.C.oneDayAgo();
|
||||||
|
} else {
|
||||||
|
return Util.M.daysAgo(days);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// up to 10 weeks use weeks
|
// up to 10 weeks use weeks
|
||||||
if (ageMillis < 10 * WEEK_IN_MILLIS) {
|
if (ageMillis < 10 * WEEK_IN_MILLIS) {
|
||||||
return Util.M.weeksAgo(round(ageMillis, WEEK_IN_MILLIS));
|
long weeks = round(ageMillis, WEEK_IN_MILLIS);
|
||||||
|
if (weeks == 1) {
|
||||||
|
return Util.C.oneWeekAgo();
|
||||||
|
} else {
|
||||||
|
return Util.M.weeksAgo(weeks);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// months
|
// months
|
||||||
if (ageMillis < YEAR_IN_MILLIS) {
|
if (ageMillis < YEAR_IN_MILLIS) {
|
||||||
return Util.M.monthsAgo(round(ageMillis, MONTH_IN_MILLIS));
|
long months = round(ageMillis, MONTH_IN_MILLIS);
|
||||||
|
if (months == 1) {
|
||||||
|
return Util.C.oneMonthAgo();
|
||||||
|
} else {
|
||||||
|
return Util.M.monthsAgo(months);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// up to 5 years use "year, months" rounded to months
|
// up to 5 years use "year, months" rounded to months
|
||||||
@@ -94,7 +124,12 @@ public class RelativeDateFormatter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// years
|
// years
|
||||||
return Util.M.yearsAgo(round(ageMillis, YEAR_IN_MILLIS));
|
long years = round(ageMillis, YEAR_IN_MILLIS);
|
||||||
|
if (years == 1) {
|
||||||
|
return Util.C.oneYearAgo();
|
||||||
|
} else {
|
||||||
|
return Util.M.yearsAgo(years);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static long upperLimit(long unit) {
|
private static long upperLimit(long unit) {
|
||||||
|
|||||||
@@ -198,4 +198,12 @@ public interface ChangeConstants extends Constants {
|
|||||||
String months();
|
String months();
|
||||||
String year();
|
String year();
|
||||||
String years();
|
String years();
|
||||||
|
|
||||||
|
String oneSecondAgo();
|
||||||
|
String oneMinuteAgo();
|
||||||
|
String oneHourAgo();
|
||||||
|
String oneDayAgo();
|
||||||
|
String oneWeekAgo();
|
||||||
|
String oneMonthAgo();
|
||||||
|
String oneYearAgo();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -180,3 +180,11 @@ month = month
|
|||||||
months = months
|
months = months
|
||||||
years = years
|
years = years
|
||||||
year = year
|
year = year
|
||||||
|
|
||||||
|
oneSecondAgo = 1 second ago
|
||||||
|
oneMinuteAgo = 1 minute ago
|
||||||
|
oneHourAgo = 1 hour ago
|
||||||
|
oneDayAgo = 1 day ago
|
||||||
|
oneWeekAgo = 1 week ago
|
||||||
|
oneMonthAgo = 1 month ago
|
||||||
|
oneYearAgo = 1 year ago
|
||||||
|
|||||||
Reference in New Issue
Block a user