diff options
author | Marvin Borner | 2019-03-05 01:09:01 +0100 |
---|---|---|
committer | Marvin Borner | 2019-03-05 01:09:01 +0100 |
commit | 55457187d18221e76bd12f0fb2cfab65c49b92fb (patch) | |
tree | 8db042d2d80710d54100c2709ad4332153ac848a /slstatus/components/datetime.c |
Initial commit
Diffstat (limited to 'slstatus/components/datetime.c')
-rw-r--r-- | slstatus/components/datetime.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/slstatus/components/datetime.c b/slstatus/components/datetime.c new file mode 100644 index 0000000..c3efae3 --- /dev/null +++ b/slstatus/components/datetime.c @@ -0,0 +1,19 @@ +/* See LICENSE file for copyright and license details. */ +#include <stdio.h> +#include <time.h> + +#include "../util.h" + +const char * +datetime(const char *fmt) +{ + time_t t; + + t = time(NULL); + if (!strftime(buf, sizeof(buf), fmt, localtime(&t))) { + warn("strftime: Result string exceeds buffer size"); + return NULL; + } + + return buf; +} |