Xinqi Bao's Git
projects
/
slstatus.git
/ blob
summary
|
log
|
commit
|
diff
|
tree
history
|
raw
|
HEAD
wifi_perc: Simplify on Linux
[slstatus.git]
/
components
/
datetime.c
1
/* See LICENSE file for copyright and license details. */
2
#include <stdio.h>
3
#include <time.h>
4
5
#include
"../util.h"
6
7
const char
*
8
datetime
(
const char
*
fmt
)
9
{
10
time_t
t
;
11
12
t
=
time
(
NULL
);
13
if
(!
strftime
(
buf
,
sizeof
(
buf
),
fmt
,
localtime
(&
t
))) {
14
warn
(
"strftime: Result string exceeds buffer size"
);
15
return
NULL
;
16
}
17
18
return
buf
;
19
}