Skip to content

Commit

Permalink
[core] Change the RemainingFormatter to reflect non-plural times, fix…
Browse files Browse the repository at this point in the history
…ing brianfrankcooper#825.

NOTE if you parse the standard out of YCSB, you'll be missing the "s" sometimes.
  • Loading branch information
manolama committed Sep 19, 2017
1 parent d6e57c3 commit 4e84b76
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions core/src/main/java/com/yahoo/ycsb/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -331,25 +331,25 @@ public static StringBuilder format(long seconds) {
StringBuilder time = new StringBuilder();
long days = TimeUnit.SECONDS.toDays(seconds);
if (days > 0) {
time.append(days).append(" days ");
time.append(days).append(days == 1 ? " day " : " days ");
seconds -= TimeUnit.DAYS.toSeconds(days);
}
long hours = TimeUnit.SECONDS.toHours(seconds);
if (hours > 0) {
time.append(hours).append(" hours ");
time.append(hours).append(hours == 1 ? " hour " : " hours ");
seconds -= TimeUnit.HOURS.toSeconds(hours);
}
/* Only include minute granularity if we're < 1 day. */
if (days < 1) {
long minutes = TimeUnit.SECONDS.toMinutes(seconds);
if (minutes > 0) {
time.append(minutes).append(" minutes ");
time.append(minutes).append(minutes == 1 ? " minute " : " minutes ");
seconds -= TimeUnit.MINUTES.toSeconds(seconds);
}
}
/* Only bother to include seconds if we're < 1 minute */
if (time.length() == 0) {
time.append(seconds).append(" seconds ");
time.append(seconds).append(time.length() == 1 ? " second " : " seconds ");
}
return time;
}
Expand Down

0 comments on commit 4e84b76

Please sign in to comment.