diff options
Diffstat (limited to 'src/stclock.c')
-rw-r--r-- | src/stclock.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/stclock.c b/src/stclock.c index 7591825..22dae6a 100644 --- a/src/stclock.c +++ b/src/stclock.c @@ -17,11 +17,18 @@ #include <time.h> #include <stdio.h> +#include "../lib/util.h" + int main(void) { - time_t t = time(NULL); - struct tm *tm = localtime(&t); - printf("%02d:%02d", tm->tm_hour, tm->tm_min); + time_t t; + char buf[64]; + + t = time(NULL); + if (!strftime(buf, sizeof(buf), "%F %T", localtime(&t))) + die("strftime: Result string exceeds buffer size"); + + printf("%s", buf); return 0; } |