Merge pull request #5 from NicolasVanBossuyt/patch-1
Uptime: making the ouput prettier
This commit is contained in:
commit
1e0e5b492b
Notes:
sideshowbarker
2024-07-19 14:42:59 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/1e0e5b492b8 Pull-request: https://github.com/SerenityOS/serenity/pull/5
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
Reference in a new issue