ttimeutil.c - stopwatch - simple timer for console or x root window | |
git clone git://src.adamsgaard.dk/stopwatch | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
ttimeutil.c (488B) | |
--- | |
1 #include <stdio.h> | |
2 #include <string.h> | |
3 | |
4 void | |
5 format_time(char *out, size_t outsiz, size_t t_elapsed, char *prefix, ch… | |
6 { | |
7 size_t h = 0, m = 0, s = 0; | |
8 | |
9 h = t_elapsed / 3600; | |
10 m = (t_elapsed % 3600) / 60; | |
11 s = t_elapsed % 60; | |
12 | |
13 if (h > 0) | |
14 snprintf(out, outsiz, "%s%lld:%02lld:%02lld%s", | |
15 prefix, h, m, s, postfix); | |
16 else if (m > 0) | |
17 snprintf(out, outsiz, "%s%lld:%02lld%s", prefix, m, s, p… | |
18 else | |
19 snprintf(out, outsiz, "%s%lld s%s", prefix, s, postfix); | |
20 } |