Xinqi Bao's Git

827381bbadcdd40a0c0ccadb0fdc3ec4279f2b46
[slstatus.git] / uptime.c
1 /* See LICENSE file for copyright and license details. */
2 #include <sys/sysinfo.h>
3
4 #include "util.h"
5
6 const char *
7 uptime(void)
8 {
9 struct sysinfo info;
10 int h = 0;
11 int m = 0;
12
13 sysinfo(&info);
14 h = info.uptime / 3600;
15 m = (info.uptime - h * 3600 ) / 60;
16
17 return bprintf("%dh %dm", h, m);
18 }