mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-13 11:39:43 +00:00
Uptime: making the ouput prettier
Just like the -p option on linux
This commit is contained in:
parent
c0fe48635b
commit
12f2d1f2e8
Notes:
sideshowbarker
2024-07-19 14:43:09 +09:00
Author: https://github.com/sleepy-monax 🔰
Commit: 12f2d1f2e8
Pull-request: https://github.com/SerenityOS/serenity/pull/5
Reviewed-by: https://github.com/awesomekling ✅
1 changed files with 17 additions and 6 deletions
|
@ -18,12 +18,23 @@ int main(int, char**)
|
||||||
unsigned seconds;
|
unsigned seconds;
|
||||||
sscanf(buffer, "%u", &seconds);
|
sscanf(buffer, "%u", &seconds);
|
||||||
|
|
||||||
printf("Up %d day%s, ", seconds / 86400, (seconds / 86400) == 1 ? "" : "s");
|
printf("Up ");
|
||||||
|
|
||||||
|
if (seconds / 86400 > 0) {
|
||||||
|
printf("%d day%s, ", seconds / 86400, (seconds / 86400) == 1 ? "" : "s");
|
||||||
seconds %= 86400;
|
seconds %= 86400;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (seconds / 3600 > 0) {
|
||||||
printf("%d hour%s, ", seconds / 3600, (seconds / 3600) == 1 ? "" : "s");
|
printf("%d hour%s, ", seconds / 3600, (seconds / 3600) == 1 ? "" : "s");
|
||||||
seconds %= 3600;
|
seconds %= 3600;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (seconds / 60 > 0) {
|
||||||
printf("%d minute%s, ", seconds / 60, (seconds / 60) == 1 ? "" : "s");
|
printf("%d minute%s, ", seconds / 60, (seconds / 60) == 1 ? "" : "s");
|
||||||
seconds %= 60;
|
seconds %= 60;
|
||||||
|
}
|
||||||
|
|
||||||
printf("%d second%s\n", seconds, seconds == 1 ? "" : "s");
|
printf("%d second%s\n", seconds, seconds == 1 ? "" : "s");
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue