Replaced ifs with a switch statement for printing uptime
This commit is contained in:
parent
daabd44a9e
commit
b767645854
1 changed files with 10 additions and 6 deletions
16
uwufetch.c
16
uwufetch.c
|
@ -338,15 +338,19 @@ void print_info()
|
||||||
#else
|
#else
|
||||||
uptime = sys.uptime;
|
uptime = sys.uptime;
|
||||||
#endif
|
#endif
|
||||||
if (uptime < 3600)
|
switch (uptime) {
|
||||||
printf("\033[18C%s%sUWUPTIME %s%lim\n",
|
case 0 ... 3599:
|
||||||
|
printf("\033[18C%s%sUWUPTIME %s%lim\n",
|
||||||
NORMAL, BOLD, NORMAL, uptime / 60 % 60);
|
NORMAL, BOLD, NORMAL, uptime / 60 % 60);
|
||||||
else if (uptime / 3600 < 24)
|
break;
|
||||||
printf("\033[18C%s%sUWUPTIME %s%lih, %lim\n",
|
case 3600 ... 86399:
|
||||||
|
printf("\033[18C%s%sUWUPTIME %s%lih, %lim\n",
|
||||||
NORMAL, BOLD, NORMAL, uptime / 3600, uptime / 60 % 60);
|
NORMAL, BOLD, NORMAL, uptime / 3600, uptime / 60 % 60);
|
||||||
else
|
break;
|
||||||
printf("\033[18C%s%sUWUPTIME %s%lid, %lih, %lim\n",
|
default:
|
||||||
|
printf("\033[18C%s%sUWUPTIME %s%lid, %lih, %lim\n",
|
||||||
NORMAL, BOLD, NORMAL, uptime / 86400, uptime / 3600 % 24, uptime / 60 % 60);
|
NORMAL, BOLD, NORMAL, uptime / 86400, uptime / 3600 % 24, uptime / 60 % 60);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (show_colors)
|
if (show_colors)
|
||||||
printf("\033[18C%s%s\u2587\u2587%s\u2587\u2587%s\u2587\u2587%s\u2587\u2587%s\u2587\u2587%s\u2587\u2587%s\u2587\u2587%s\u2587\u2587%s\n",
|
printf("\033[18C%s%s\u2587\u2587%s\u2587\u2587%s\u2587\u2587%s\u2587\u2587%s\u2587\u2587%s\u2587\u2587%s\u2587\u2587%s\u2587\u2587%s\n",
|
||||||
|
|
Loading…
Reference in a new issue