projects
/
sysstatus.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
42b37aafb389006661ba4b5d4986db3b594f3f9e
[sysstatus.git]
/
statuses
/
datetime.c
1
#include <stdio.h>
2
#include <time.h>
3
#include "datetime.h"
4
#include "../config.h"
5
6
void status_datetime()
7
{
8
time_t nows = 0;
9
struct tm *nowtm;
10
11
nows = time(NULL);
12
if (nows == ((time_t) -1))
13
{
14
printf(" ^fg(red)ERROR: DATETIME");
15
return;
16
}
17
18
nowtm = localtime(&nows);
19
20
printf(" ^fg(#666666)%d.%d.%d ^fg(grey)%d:%.2d"
21
22
#ifdef SHOW_SECONDS
23
":%.2d"
24
#endif
25
" "
26
,nowtm -> tm_mday,
27
(nowtm -> tm_mon) + 1,
28
(nowtm -> tm_year) + 1900,
29
nowtm -> tm_hour,
30
nowtm -> tm_min
31
32
#ifdef SHOW_SECONDS
33
,nowtm -> tm_sec
34
#endif
35
36
);
37
}