diff options
| author | Max <mahn.maxwell@gmail.com> | 2022-05-11 08:45:45 -0400 |
|---|---|---|
| committer | Max <mahn.maxwell@gmail.com> | 2022-05-11 08:45:45 -0400 |
| commit | 0018b2277da84417c9836149b1f1240f8d3850b7 (patch) | |
| tree | fba68d40f32052c4783476696a67b4b9956dcc8b /components/datetime.c | |
Diffstat (limited to 'components/datetime.c')
| -rw-r--r-- | components/datetime.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/components/datetime.c b/components/datetime.c new file mode 100644 index 0000000..c3efae3 --- /dev/null +++ b/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; +} |
