whattime: Show 0 minutes in pretty output

When supplying the -p command to uptime, it does not display any
sections where the value is less than 1; however, after a reboot, this
causes the command to just output "up". Showing 0 minutes when the
system has been up for less than a minute makes it clear a reboot just
occurred.

References:
 commit 325d68b7c3

Signed-off-by: Craig Small <csmall@enc.com.au>
This commit is contained in:
Kyle Laker 2017-09-25 08:36:51 +10:00 committed by Craig Small
parent c22fc57276
commit 3651280194

View File

@ -203,10 +203,10 @@ PROCPS_EXPORT char *procps_uptime_sprint_short(void)
comma += 1;
}
if (upminutes) {
if (upminutes || (!upminutes && uptime_secs < 60)) {
pos += sprintf(shortbuf + pos, "%s%d %s",
comma > 0 ? ", " : "", upminutes,
upminutes > 1 ? "minutes" : "minute");
comma > 0 ? ", " : "", upminutes,
upminutes != 1 ? "minutes" : "minute");
comma += 1;
}
return shortbuf;