X-Git-Url: https://git.xinqibao.xyz/slstatus.git/blobdiff_plain/8e25af7dc33bdcc0df6f4f173da7a2f883141d70..6820631175868c277effa7cc05f9cb3197b72654:/uptime.c diff --git a/uptime.c b/uptime.c new file mode 100644 index 0000000..c9f4fda --- /dev/null +++ b/uptime.c @@ -0,0 +1,17 @@ +#include + +#include "util.h" + +const char * +uptime(void) +{ + struct sysinfo info; + int h = 0; + int m = 0; + + sysinfo(&info); + h = info.uptime / 3600; + m = (info.uptime - h * 3600 ) / 60; + + return bprintf("%dh %dm", h, m); +}