blob: d7d9d0a4e78407c3daf2f8310dd03c51e29e75bb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#include <stdio.h>
#include <time.h>
#include "common.h"
#include "config.h"
void status_datetime(GlobalData *g)
{
StatusItem s;
char text[32] = { 0 };
time_t nows = 0;
struct tm *nowtm;
statusitem_init(&s);
s.text = text;
nows = time(NULL);
if (nows == ((time_t) -1)) {
s.color = "red";
s.text = "ERROR: DATETIME";
line_append_item(g, &s);
} else {
nowtm = localtime(&nows);
s.color = "#666666";
snprintf(text, sizeof(text),
"%d.%d.%d",
nowtm->tm_mday,
(nowtm->tm_mon) + 1,
(nowtm->tm_year) + 1900
);
line_append_item(g, &s);
s.color = "grey";
snprintf(text, sizeof(text),
"%d:%.2d"
#ifdef SHOW_SECONDS
":%.2d"
#endif
,nowtm->tm_hour,
nowtm->tm_min
#ifdef SHOW_SECONDS
,nowtm -> tm_sec
#endif
);
line_append_item(g, &s);
}
}
|