-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalendar.c
111 lines (95 loc) · 1.61 KB
/
calendar.c
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#include <stdio.h>
#include <stddef.h>
#include <time.h>
#include <conio.h>
#include "calendar.h"
typedef struct {
int min: 8;
int hour: 16;
int kin: 5;
int winal: 4;
int tun: 5;
int katun: 8;
} LongCount;
LongCount today;
char todaysDate[20];
char *tzolkin_name[] =
{
"ha' ",
"ik' ",
"ak'ab ",
"ohl ",
"chikchan",
"cham ",
"chij ",
"lamat ",
"muluk ",
"oc ",
"chuwen ",
"eb' ",
"b'en ",
"hish ",
"tz'ikin ",
"kib' ",
"kab ",
"etz'nab ",
"kawak ",
"ajaw "
};
char *haab_name[] = {
" pop",
" wo'",
" sip",
"sotz'",
" sek",
" xul",
" yax",
" mol",
"ch'en",
" yax",
" sak'",
" keh",
" mak",
" k'an",
"muwan",
" pax",
"'ayab",
" k'u"
};
time_t now; // Unsigned Long
unsigned char kin;
void updateDate()
{
unsigned char newKin, winal, katun, baktun;
time(&now);
newKin = (now/20) % 20;
if (newKin == kin) return; // nothing to do
//
// date has changed
//
kin = newKin;
winal = (now/400) % 20;
katun = (now/8000) % 20;
baktun = (now/160000) % 20;
sprintf(todaysDate, "%02d.%02d.%02d.%02d",
kin,
winal,
katun,
baktun);
cputsxy(20,52,todaysDate);
}
char *thaHaab()
{
unsigned char trecena, kin, haab;
time(&now);
now >>= 4;
trecena = now % 13;
kin = now % 20;
haab = (now/20) % 18;
sprintf(todaysDate, "%s %02d %s",
haab_name[haab],
trecena+1,
tzolkin_name[kin]
);
return todaysDate;
}