summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Userland/uptime.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/Userland/uptime.cpp b/Userland/uptime.cpp
index fc0b852bfa..4ee6717f6a 100644
--- a/Userland/uptime.cpp
+++ b/Userland/uptime.cpp
@@ -18,12 +18,23 @@ int main(int, char**)
unsigned seconds;
sscanf(buffer, "%u", &seconds);
- printf("Up %d day%s, ", seconds / 86400, (seconds / 86400) == 1 ? "" : "s");
- seconds %= 86400;
- printf("%d hour%s, ", seconds / 3600, (seconds / 3600) == 1 ? "" : "s");
- seconds %= 3600;
- printf("%d minute%s, ", seconds / 60, (seconds / 60) == 1 ? "" : "s");
- seconds %= 60;
+ printf("Up ");
+
+ if (seconds / 86400 > 0) {
+ printf("%d day%s, ", seconds / 86400, (seconds / 86400) == 1 ? "" : "s");
+ seconds %= 86400;
+ }
+
+ if (seconds / 3600 > 0) {
+ printf("%d hour%s, ", seconds / 3600, (seconds / 3600) == 1 ? "" : "s");
+ seconds %= 3600;
+ }
+
+ if (seconds / 60 > 0) {
+ printf("%d minute%s, ", seconds / 60, (seconds / 60) == 1 ? "" : "s");
+ seconds %= 60;
+ }
+
printf("%d second%s\n", seconds, seconds == 1 ? "" : "s");
fclose(fp);