#include <time.h>
#include "stdio.h"
#include "string.h"
unsigned int LunarCalendarDay;
unsigned int LunarCalendarTable[199]
=
//
保存农历年信息
{
0
x
04
A
E
53
,
0
x
0
A
5748
,
0
x
5526B
D
,
0
x
0
D
2650
,
0
x
0
D
9544
,
0
x
46
AA
B9
,
0
x
056
A
4
D
,
0
x
09
A
D
42
,
0
x
24
A
E
B6
,
0
x
04
A
E
4
A
,
/
*
1901
-
1910
*
/
0
x
6
A
4
D
B
E
,
0
x
0
A
4
D
52
,
0
x
0
D
2546
,
0
x
5
D
52B
A
,
0
x
0B544
E
,
0
x
0
D
6
A
43
,
0
x
296
D
37
,
0
x
095B4B
,
0
x
749B
C
1
,
0
x
049754
,
/
*
1911
-
1920
*
/
0
x
0
A
4B48
,
0
x
5B25B
C
,
0
x
06
A
550
,
0
x
06
D
445
,
0
x
4
A
D
A
B8
,
0
x
02B64
D
,
0
x
095742
,
0
x
2497B7
,
0
x
04974
A
,
0
x
664B3
E
,
/
*
1921
-
1930
*
/
0
x
0
D
4
A
51
,
0
x
0
E
A
546
,
0
x
56
D
4B
A
,
0
x
05
A
D
4
E
,
0
x
02B644
,
0
x
393738
,
0
x
092
E
4B
,
0
x
7
C
96B
F
,
0
x
0
C
9553
,
0
x
0
D
4
A
48
,
/
*
1931
-
1940
*
/
0
x
6
D
A
53B
,
0
x
0B554
F
,
0
x
056
A
45
,
0
x
4
AA
D
B9
,
0
x
025
D
4
D
,
0
x
092
D
42
,
0
x
2
C
95B6
,
0
x
0
A
954
A
,
0
x
7B4
A
B
D
,
0
x
06
C
A
51
,
/
*
1941
-
1950
*
/
0
x
0B5546
,
0
x
555
A
BB
,
0
x
04
D
A
4
E
,
0
x
0
A
5B43
,
0
x
352BB8
,
0
x
052B4
C
,
0
x
8
A
953
F
,
0
x
0
E
9552
,
0
x
06
AA
48
,
0
x
6
A
D
53
C
,
/
*
1951
-
1960
*
/
0
x
0
A
B54
F
,
0
x
04B645
,
0
x
4
A
5739
,
0
x
0
A
574
D
,
0
x
052642
,
0
x
3
E
9335
,
0
x
0
D
9549
,
0
x
75
AA
B
E
,
0
x
056
A
51
,
0
x
096
D
46
,
/
*
1961
-
1970
*
/
0
x
54
A
E
BB
,
0
x
04
A
D
4
F
,
0
x
0
A
4
D
43
,
0
x
4
D
26B7
,
0
x
0
D
254B
,
0
x
8
D
52B
F
,
0
x
0B5452
,
0
x
0B6
A
47
,
0
x
696
D
3
C
,
0
x
095B50
,
/
*
1971
-
1980
*
/
0
x
049B45
,
0
x
4
A
4BB9
,
0
x
0
A
4B4
D
,
0
x
A
B25
C
2
,
0
x
06
A
554
,
0
x
06
D
449
,
0
x
6
A
D
A
3
D
,
0
x
0
A
B651
,
0
x
093746
,
0
x
5497BB
,
/
*
1981
-
1990
*
/
0
x
04974
F
,
0
x
064B44
,
0
x
36
A
537
,
0
x
0
E
A
54
A
,
0
x
86B2B
F
,
0
x
05
A
C
53
,
0
x
0
A
B647
,
0
x
5936B
C
,
0
x
092
E
50
,
0
x
0
C
9645
,
/
*
1991
-
2000
*
/
0
x
4
D
4
A
B8
,
0
x
0
D
4
A
4
C
,
0
x
0
D
A
541
,
0
x
25
AA
B6
,
0
x
056
A
49
,
0
x
7
AA
D
B
D
,
0
x
025
D
52
,
0
x
092
D
47
,
0
x
5
C
95B
A
,
0
x
0
A
954
E
,
/
*
2001
-
2010
*
/
0
x
0B4
A
43
,
0
x
4B5537
,
0
x
0
A
D
54
A
,
0
x
955
A
B
F
,
0
x
04B
A
53
,
0
x
0
A
5B48
,
0
x
652BB
C
,
0
x
052B50
,
0
x
0
A
9345
,
0
x
474
A
B9
,
/
*
2011
-
2020
*
/
0
x
06
AA
4
C
,
0
x
0
A
D
541
,
0
x
24
D
A
B6
,
0
x
04B64
A
,
0
x
69573
D
,
0
x
0
A
4
E
51
,
0
x
0
D
2646
,
0
x
5
E
933
A
,
0
x
0
D
534
D
,
0
x
05
AA
43
,
/
*
2021
-
2030
*
/
0
x
36B537
,
0
x
096
D
4B
,
0
x
B4
A
E
B
F
,
0
x
04
A
D
53
,
0
x
0
A
4
D
48
,
0
x
6
D
25B
C
,
0
x
0
D
254
F
,
0
x
0
D
5244
,
0
x
5
D
AA
38
,
0
x
0B5
A
4
C
,
/
*
2031
-
2040
*
/
0
x
056
D
41
,
0
x
24
A
D
B6
,
0
x
049B4
A
,
0
x
7
A
4BB
E
,
0
x
0
A
4B51
,
0
x
0
AA
546
,
0
x
5B52B
A
,
0
x
06
D
24
E
,
0
x
0
A
D
A
42
,
0
x
355B37
,
/
*
2041
-
2050
*
/
0
x
09374B
,
0
x
8497
C
1
,
0
x
049753
,
0
x
064B48
,
0
x
66
A
53
C
,
0
x
0
E
A
54
F
,
0
x
06B244
,
0
x
4
A
B638
,
0
x
0
AA
E
4
C
,
0
x
092
E
42
,
/
*
2051
-
2060
*
/
0
x
3
C
9735
,
0
x
0
C
9649
,
0
x
7
D
4
A
B
D
,
0
x
0
D
4
A
51
,
0
x
0
D
A
545
,
0
x
55
AA
B
A
,
0
x
056
A
4
E
,
0
x
0
A
6
D
43
,
0
x
452
E
B7
,
0
x
052
D
4B
,
/
*
2061
-
2070
*
/
0
x
8
A
95B
F
,
0
x
0
A
9553
,
0
x
0B4
A
47
,
0
x
6B553B
,
0
x
0
A
D
54
F
,
0
x
055
A
45
,
0
x
4
A
5
D
38
,
0
x
0
A
5B4
C
,
0
x
052B42
,
0
x
3
A
93B6
,
/
*
2071
-
2080
*
/
0
x
069349
,
0
x
7729B
D
,
0
x
06
AA
51
,
0
x
0
A
D
546
,
0
x
54
D
A
B
A
,
0
x
04B64
E
,
0
x
0
A
5743
,
0
x
452738
,
0
x
0
D
264
A
,
0
x
8
E
933
E
,
/
*
2081
-
2090
*
/
0
x
0
D
5252
,
0
x
0
D
AA
47
,
0
x
66B53B
,
0
x
056
D
4
F
,
0
x
04
A
E
45
,
0
x
4
A
4
E
B9
,
0
x
0
A
4
D
4
C
,
0
x
0
D
1541
,
0
x
2
D
92B5
/
*
2091
-
2099
*
/
};
i
n
t
M
o
n
t
hA
dd
[
12
]
=
{
0
,
31
,
59
,
90
,
120
,
151
,
181
,
212
,
243
,
273
,
304
,
334
}
;
//
记录公历每个月之前的天数
int LunarCalendar(int year,int month,int day)
{
int Spring_NY,Sun_NY,StaticDayCount;
int index,flag;
//
S
p
r
i
n
g
_
N
Y
记录春节离当年元旦的天数。
//
S
un
_
N
Y
记录公历日离当年元旦的天数。
if ( ((LunarCalendarTable[year-1901] & 0x0060)
>>
5)
==
1)
Spring_NY = (LunarCalendarTable[year-1901] & 0x001F) - 1;
else
Spring_NY = (LunarCalendarTable[year-1901] & 0x001F) - 1 + 31;
Sun_NY
=
MonthAdd[month-1]
+
day - 1;
if ( (!(year % 4)) && (month > 2))
Sun_NY++;
//
S
t
a
t
i
c
D
a
y
C
o
un
t
记录大小月的天数
29
或
30
//index 记录从哪个月开始来计算。
//flag
是用来对闰月的特殊处理。
//判断阳历日在春节前还是春节后
i
f
(
S
un
_
N
Y
>=
S
p
r
i
n
g
_
N
Y
)
//
阳历日在春节后(含春节那天)
{
Sun_NY -= Spring_NY;
month
=
1;
index = 1;
flag
=
0;
if ( ( LunarCalendarTable[year - 1901] & (0x80000
>>
(index-1)) ) ==0)
StaticDayCount
=
29;
else
StaticDayCount = 30;
while (Sun_NY >= StaticDayCount)
{
Sun_NY -= StaticDayCount;