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