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.
This commit is contained in:
Kyle Laker 2017-03-23 10:53:55 -04:00 committed by Craig Small
parent 53e101452f
commit 325d68b7c3

View File

@ -146,10 +146,10 @@ char *sprint_uptime(int human_readable) {
comma += 1; comma += 1;
} }
if (upminutes) { if (upminutes || (!upminutes && uptime_secs < 60)) {
pos += sprintf(buf + pos, "%s%d %s", comma > 0 ? ", " : "", upminutes, pos += sprintf(buf + pos, "%s%d %s", comma > 0 ? ", " : "", upminutes,
upminutes > 1 ? "minutes" : "minute"); upminutes != 1 ? "minutes" : "minute");
comma += 1; comma += 1;
} }
} }