Skip to content
Snippets Groups Projects
Commit 71a9ee5d authored by Chris Larsen's avatar Chris Larsen Committed by GitHub
Browse files

Merge pull request #1029 from manolama/i825

[core] Change the RemainingFormatter to reflect non-plural times, fix…
parents d6e57c3f 4e84b763
No related branches found
No related tags found
No related merge requests found
...@@ -331,25 +331,25 @@ final class RemainingFormatter { ...@@ -331,25 +331,25 @@ final class RemainingFormatter {
StringBuilder time = new StringBuilder(); StringBuilder time = new StringBuilder();
long days = TimeUnit.SECONDS.toDays(seconds); long days = TimeUnit.SECONDS.toDays(seconds);
if (days > 0) { if (days > 0) {
time.append(days).append(" days "); time.append(days).append(days == 1 ? " day " : " days ");
seconds -= TimeUnit.DAYS.toSeconds(days); seconds -= TimeUnit.DAYS.toSeconds(days);
} }
long hours = TimeUnit.SECONDS.toHours(seconds); long hours = TimeUnit.SECONDS.toHours(seconds);
if (hours > 0) { if (hours > 0) {
time.append(hours).append(" hours "); time.append(hours).append(hours == 1 ? " hour " : " hours ");
seconds -= TimeUnit.HOURS.toSeconds(hours); seconds -= TimeUnit.HOURS.toSeconds(hours);
} }
/* Only include minute granularity if we're < 1 day. */ /* Only include minute granularity if we're < 1 day. */
if (days < 1) { if (days < 1) {
long minutes = TimeUnit.SECONDS.toMinutes(seconds); long minutes = TimeUnit.SECONDS.toMinutes(seconds);
if (minutes > 0) { if (minutes > 0) {
time.append(minutes).append(" minutes "); time.append(minutes).append(minutes == 1 ? " minute " : " minutes ");
seconds -= TimeUnit.MINUTES.toSeconds(seconds); seconds -= TimeUnit.MINUTES.toSeconds(seconds);
} }
} }
/* Only bother to include seconds if we're < 1 minute */ /* Only bother to include seconds if we're < 1 minute */
if (time.length() == 0) { if (time.length() == 0) {
time.append(seconds).append(" seconds "); time.append(seconds).append(time.length() == 1 ? " second " : " seconds ");
} }
return time; return time;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment