mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:47:45 +00:00
Uptime: making the ouput prettier
Just like the -p option on linux
This commit is contained in:
parent
c0fe48635b
commit
12f2d1f2e8
1 changed files with 17 additions and 6 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue