Xinqi Bao's Git

b45518289be3b56358eeadfd58fc983d96f03679
[slstatus.git] / components / 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 }