suckless/slstatus

components/datetime.c in master
Repositories | Summary | Log | Files | README | LICENSE

datetime.c (358B) download


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