aboutsummaryrefslogtreecommitdiffstats
path: root/status/time.c
blob: f02e2bf0024bd7485f99d8f148f9b5730a4a1661 (plain) (blame)
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
54
55
56
57
58
59

#include "kconfig.h"
#include "dwmstatus.h"

int print_time( bbuf *buf )
{
	ASSERT( buf != NULL );

	int str_size=0;

	if ( buf->size < 1 )
	{
		buf->size = 1024;
		buf->str = malloc( buf->size );
	}

	time_t tim;
	struct tm *timtm;

	memset(buf->str, 0, buf->size);
	//settz(tzname);
	time( &tim );
	timtm = localtime( &tim );
	if (timtm == NULL) 
	{
		perror("localtime");
		//exit(1);
	}
#ifdef CONFIG_STATUS_UTF8
	/*
	buf->str[0] = 0x20;
	buf->str[1] = 0xef;
	buf->str[2] = 0x8d;
	buf->str[3] = 0xae;
	str_size = 2;
	*/
	//nerd f64f, //ef 99 8f
	buf->str[0] = 0xef;
	buf->str[1] = 0x99;
	buf->str[2] = 0x8f;
	str_size = 3;
	printf("asd1 [%s]\n", buf->str);
#endif

	//printf("%s",asctime(timtm));
	strftime(&buf->str[str_size], buf->size-1-str_size,"%H:%M ", timtm);
	//if (!strftime(buf->str, buf->size-1, "%H:%M", timtm)) 
	//{
	//	fprintf(stderr, "strftime == 0\n");
		//exit(1);
	//}

	
	printf("asd1 [%s]\n", buf->str);
	//wprintf(L"asd2 [%ls]\n", buf->str);
	return 0;
}