Xinqi Bao's Git

6dc9678b26264ee682b386b7dfefe3b9055ba8b1
[slstatus.git] / components / datetime.c
1 /* See LICENSE file for copyright and license details. */
2 #include <time.h>
3
4 #include "../util.h"
5
6 const char *
7 datetime(const char *fmt)
8 {
9 time_t t;
10
11 t = time(NULL);
12 if (!strftime(buf, sizeof(buf), fmt, localtime(&t))) {
13 fprintf(stderr, "strftime: Result string exceeds buffer size\n");
14 return NULL;
15 }
16
17 return buf;
18 }