Xinqi Bao's Git

Change uint64_t to uintmax_t
[slstatus.git] / components / uptime.c
1 /* See LICENSE file for copyright and license details. */
2 #include <inttypes.h>
3 #include <stdio.h>
4 #include <time.h>
5
6 #include "../util.h"
7
8 const char *
9 uptime(void)
10 {
11 uintmax_t h, m;
12 struct timespec uptime;
13
14 if (clock_gettime(CLOCK_BOOTTIME, &uptime) < 0) {
15 warn("clock_gettime 'CLOCK_BOOTTIME'");
16 return NULL;
17 }
18
19 h = uptime.tv_sec / 3600;
20 m = uptime.tv_sec % 3600 / 60;
21
22 return bprintf("%" PRIuMAX "h %" PRIuMAX "m", h, m);
23 }