summaryrefslogtreecommitdiff
path: root/statuses/datetime.c
blob: 7c0e47968e7b2797f492896505747e4a69769d0e (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
#include <stdio.h>
#include <time.h>
#include "datetime.h"
#include "../config.h"

void status_datetime()
{
	time_t nows = 0;
	struct tm *nowtm;
	
	nows = time(NULL);
	if (nows != ((time_t) -1))
	{
		nowtm = localtime(&nows);
		
		printf(" ^fg(#666666)%d.%d.%d  ^fg(grey)%d:%.2d"
			
			#ifdef SHOW_SECONDS
			":%.2d"
			#endif
			" "
			,nowtm -> tm_mday,
			(nowtm -> tm_mon) + 1,
			(nowtm -> tm_year) + 1900,
			nowtm -> tm_hour,
			nowtm -> tm_min
			
			#ifdef SHOW_SECONDS
			,nowtm -> tm_sec
			#endif
			
			);
	}
	else
		printf(" ^fg(red)ERROR: DATETIME");
}