1
/* $Id: tables.h,v 1.4 2001/10/29 05:55:39 fflee Exp $ */
3
/*----------------------------------------------------------------------------
4
# Copyright (C) 1988,1989,1991,1992,2001 Fung F. Lee and Ricky Yeung
7
# This program is free software; you can redistribute it and/or
8
# modify it under the terms of the GNU General Public License
9
# as published by the Free Software Foundation; either version 2
10
# of the License, or any later version.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with this program; if not, write to the Free Software Foundation,
19
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
----------------------------------------------------------------------------*/
23
* tables.h: contains tables and parameters for lunar.c
25
#define Cyear 1900 /* Note that LC1900.1.1 is SC1900.1.31 */
26
#define Nyear 150 /* number of years covered by the table */
27
#define Nmonth 13 /* maximum number of months in a lunar year */
29
static Date SolarFirstDate = {
30
/* Wednesday, 12 a.m., 31 January, 1900 */
34
static Date LunarFirstDate = {
35
/* Wednesday, 12 a.m., First day, First month, 1900 */
39
static Date GanFirstDate = {
40
/* geng1-nian2 wu4-yue4 jia3-ri4 jia3-shi2 */
44
static Date ZhiFirstDate = {
45
/* zi3-nian2 yin2-yue4 chen2-ri4 zi3-shi2 */
49
static long yearInfo[Nyear] = {
52
bit# 1 111111000000 0000
58
b_j = 1 for long month, b_j = 0 for short month
59
L is the leap month of the year if 1<=L<=12; NO leap month if L = 0.
60
The leap month (if exists) is long one iff M = 1.
63
0x04ae0, 0x0a570, 0x054d5, 0x0d260, 0x0d950, /* 1905 */
64
0x16554, 0x056a0, 0x09ad0, 0x055d2, 0x04ae0, /* 1910 */
65
0x0a5b6, 0x0a4d0, 0x0d250, 0x1d255, 0x0b540, /* 1915 */
66
0x0d6a0, 0x0ada2, 0x095b0, 0x14977, 0x04970, /* 1920 */
67
0x0a4b0, 0x0b4b5, 0x06a50, 0x06d40, 0x1ab54, /* 1925 */
68
0x02b60, 0x09570, 0x052f2, 0x04970, 0x06566, /* 1930 */
69
0x0d4a0, 0x0ea50, 0x06e95, 0x05ad0, 0x02b60, /* 1935 */
70
0x186e3, 0x092e0, 0x1c8d7, 0x0c950, 0x0d4a0, /* 1940 */
71
0x1d8a6, 0x0b550, 0x056a0, 0x1a5b4, 0x025d0, /* 1945 */
72
0x092d0, 0x0d2b2, 0x0a950, 0x0b557, 0x06ca0, /* 1950 */
73
0x0b550, 0x15355, 0x04da0, 0x0a5d0, 0x14573, /* 1955 */
74
0x052d0, 0x0a9a8, 0x0e950, 0x06aa0, 0x0aea6, /* 1960 */
75
0x0ab50, 0x04b60, 0x0aae4, 0x0a570, 0x05260, /* 1965 */
76
0x0f263, 0x0d950, 0x05b57, 0x056a0, 0x096d0, /* 1970 */
77
0x04dd5, 0x04ad0, 0x0a4d0, 0x0d4d4, 0x0d250, /* 1975 */
78
0x0d558, 0x0b540, 0x0b5a0, 0x195a6, 0x095b0, /* 1980 */
79
0x049b0, 0x0a974, 0x0a4b0, 0x0b27a, 0x06a50, /* 1985 */
80
0x06d40, 0x0af46, 0x0ab60, 0x09570, 0x04af5, /* 1990 */
81
0x04970, 0x064b0, 0x074a3, 0x0ea50, 0x06b58, /* 1995 */
82
0x05ac0, 0x0ab60, 0x096d5, 0x092e0, 0x0c960, /* 2000 */
83
0x0d954, 0x0d4a0, 0x0da50, 0x07552, 0x056a0, /* 2005 */
84
0x0abb7, 0x025d0, 0x092d0, 0x0cab5, 0x0a950, /* 2010 */
85
0x0b4a0, 0x0baa4, 0x0ad50, 0x055d9, 0x04ba0, /* 2015 */
86
0x0a5b0, 0x15176, 0x052b0, 0x0a930, 0x07954, /* 2020 */
87
0x06aa0, 0x0ad50, 0x05b52, 0x04b60, 0x0a6e6, /* 2025 */
88
0x0a4e0, 0x0d260, 0x0ea65, 0x0d530, 0x05aa0, /* 2030 */
89
0x076a3, 0x096d0, 0x04bd7, 0x04ad0, 0x0a4d0, /* 2035 */
90
0x1d0b6, 0x0d250, 0x0d520, 0x0dd45, 0x0b5a0, /* 2040 */
91
0x056d0, 0x055b2, 0x049b0, 0x0a577, 0x0a4b0, /* 2045 */
92
0x0aa50, 0x1b255, 0x06d20, 0x0ada0 /* 2049 */
96
In "4-column" calculation, a "mingli" (fortune-telling) calculation,
97
the beginning of a month is not the first day of the month as in
98
the Lunar Calendar; it is instead governed by "jie2" (festival).
99
Interestingly, in the Solar calendar, a jie always comes around certain
100
day. For example, the jie "li4chun1" (beginning of spring) always comes
101
near Feburary 4 of the Solar Calendar.
103
Meaning of array fest:
104
Each element, fest[i][j] stores the jie day (in term of the following Solar
105
month) of the lunar i-th year, j-th month.
106
For example, in 1992, fest[92][0] is 4, that means the jie "li4chun1"
107
(beginning of spring) is on Feb. 4, 1992; fest[92][11] is 5, that means
108
the jie of the 12th lunar month is on Jan. 5, 1993.
111
static byte fest[Nyear][12] = {
112
{4, 6, 5, 6, 6, 7, 8, 8, 9, 8, 7, 6}, /* 1900 */
113
{4, 6, 5, 6, 6, 8, 8, 8, 9, 8, 8, 6}, /* 1901 */
114
{5, 6, 6, 6, 7, 8, 8, 8, 9, 8, 8, 6}, /* 1902 */
115
{5, 7, 6, 7, 7, 8, 9, 9, 9, 8, 8, 7}, /* 1903 */
116
{5, 6, 5, 6, 6, 7, 8, 8, 9, 8, 7, 6}, /* 1904 */
117
{4, 6, 5, 6, 6, 8, 8, 8, 9, 8, 8, 6}, /* 1905 */
118
{5, 6, 6, 6, 6, 8, 8, 8, 9, 8, 8, 6}, /* 1906 */
119
{5, 7, 6, 7, 7, 8, 9, 9, 9, 8, 8, 7}, /* 1907 */
120
{5, 6, 5, 6, 6, 7, 8, 8, 9, 8, 7, 6}, /* 1908 */
121
{4, 6, 5, 6, 6, 8, 8, 8, 9, 8, 8, 6}, /* 1909 */
122
{5, 6, 6, 6, 6, 8, 8, 8, 9, 8, 8, 6}, /* 1910 */
123
{5, 7, 6, 7, 7, 8, 9, 9, 9, 8, 8, 7}, /* 1911 */
124
{5, 6, 5, 6, 6, 7, 8, 8, 9, 8, 7, 6}, /* 1912 */
125
{4, 6, 5, 6, 6, 8, 8, 8, 9, 8, 8, 6}, /* 1913 */
126
{4, 6, 5, 6, 6, 8, 8, 8, 9, 8, 8, 6}, /* 1914 */
127
{5, 6, 6, 6, 7, 8, 8, 9, 9, 8, 8, 6}, /* 1915 */
128
{5, 6, 5, 6, 6, 7, 8, 8, 8, 8, 7, 6}, /* 1916 */
129
{4, 6, 5, 6, 6, 8, 8, 8, 9, 8, 7, 6}, /* 1917 */
130
{4, 6, 5, 6, 6, 8, 8, 8, 9, 8, 8, 6}, /* 1918 */
131
{5, 6, 6, 6, 7, 8, 8, 9, 9, 8, 8, 6}, /* 1919 */
132
{5, 6, 5, 6, 6, 7, 8, 8, 8, 8, 7, 6}, /* 1920 */
133
{4, 6, 5, 6, 6, 8, 8, 8, 9, 9, 7, 6}, /* 1921 */
134
{4, 6, 5, 6, 6, 8, 8, 8, 9, 8, 8, 6}, /* 1922 */
135
{5, 6, 6, 6, 7, 8, 8, 9, 9, 8, 8, 6}, /* 1923 */
136
{5, 6, 5, 6, 6, 7, 8, 8, 8, 8, 7, 6}, /* 1924 */
137
{4, 6, 5, 6, 6, 8, 8, 8, 9, 8, 7, 6}, /* 1925 */
138
{4, 6, 5, 6, 6, 8, 8, 8, 9, 8, 8, 6}, /* 1926 */
139
{5, 6, 6, 6, 7, 8, 8, 8, 9, 8, 8, 6}, /* 1927 */
140
{5, 6, 5, 6, 6, 7, 8, 8, 8, 7, 7, 6}, /* 1928 */
141
{4, 6, 5, 6, 6, 7, 8, 8, 9, 8, 7, 6}, /* 1929 */
142
{4, 6, 5, 6, 6, 8, 8, 8, 9, 8, 8, 6}, /* 1930 */
143
{5, 6, 6, 6, 7, 8, 8, 8, 9, 8, 8, 6}, /* 1931 */
144
{5, 6, 5, 6, 6, 7, 8, 8, 8, 7, 7, 6}, /* 1932 */
145
{4, 6, 5, 6, 6, 7, 8, 8, 9, 8, 7, 6}, /* 1933 */
146
{4, 6, 5, 6, 6, 8, 8, 8, 9, 8, 8, 6}, /* 1934 */
147
{5, 6, 6, 6, 6, 8, 8, 8, 9, 8, 8, 6}, /* 1935 */
148
{5, 6, 5, 6, 6, 7, 8, 8, 8, 7, 7, 6}, /* 1936 */
149
{4, 6, 5, 6, 6, 7, 8, 8, 9, 8, 7, 6}, /* 1937 */
150
{4, 6, 5, 6, 6, 8, 8, 8, 9, 8, 8, 6}, /* 1938 */
151
{5, 6, 6, 6, 6, 8, 8, 8, 9, 8, 8, 6}, /* 1939 */
152
{5, 6, 5, 6, 6, 7, 8, 8, 8, 7, 7, 6}, /* 1940 */
153
{4, 6, 5, 6, 6, 7, 8, 8, 9, 8, 7, 6}, /* 1941 */
154
{4, 6, 5, 6, 6, 8, 8, 8, 9, 8, 8, 6}, /* 1942 */
155
{5, 6, 6, 6, 6, 8, 8, 8, 9, 8, 8, 6}, /* 1943 */
156
{5, 6, 5, 5, 6, 7, 8, 8, 8, 7, 7, 6}, /* 1944 */
157
{4, 6, 5, 6, 6, 7, 8, 8, 8, 8, 7, 6}, /* 1945 */
158
{4, 6, 5, 6, 6, 8, 8, 8, 9, 8, 8, 6}, /* 1946 */
159
{4, 6, 5, 6, 6, 8, 8, 8, 9, 8, 8, 6}, /* 1947 */
160
{5, 5, 5, 5, 6, 7, 7, 8, 8, 7, 7, 5}, /* 1948 */
161
{4, 6, 5, 6, 6, 7, 8, 8, 8, 8, 7, 6}, /* 1949 */
162
{4, 6, 5, 6, 6, 8, 8, 8, 9, 8, 8, 6}, /* 1950 */
163
{4, 6, 5, 6, 6, 8, 8, 8, 9, 8, 8, 6}, /* 1951 */
164
{5, 5, 5, 5, 6, 7, 7, 8, 8, 7, 7, 5}, /* 1952 */
165
{4, 6, 5, 6, 6, 7, 8, 8, 8, 8, 7, 6}, /* 1953 */
166
{4, 6, 5, 6, 6, 8, 8, 8, 9, 8, 7, 6}, /* 1954 */
167
{4, 6, 5, 6, 6, 8, 8, 8, 9, 8, 8, 6}, /* 1955 */
168
{5, 5, 5, 5, 6, 7, 7, 8, 8, 7, 7, 5}, /* 1956 */
169
{4, 6, 5, 6, 6, 7, 8, 8, 8, 8, 7, 6}, /* 1957 */
170
{4, 6, 5, 6, 6, 7, 8, 8, 9, 8, 7, 6}, /* 1958 */
171
{4, 6, 5, 6, 6, 8, 8, 8, 9, 8, 8, 6}, /* 1959 */
172
{5, 5, 5, 5, 6, 7, 7, 7, 8, 7, 7, 5}, /* 1960 */
173
{4, 6, 5, 6, 6, 7, 8, 8, 8, 7, 7, 6}, /* 1961 */
174
{4, 6, 5, 6, 6, 7, 8, 8, 9, 8, 7, 6}, /* 1962 */
175
{4, 6, 5, 6, 6, 8, 8, 8, 9, 8, 8, 6}, /* 1963 */
176
{5, 5, 5, 5, 6, 7, 7, 7, 8, 7, 7, 5}, /* 1964 */
177
{4, 6, 5, 6, 6, 7, 8, 8, 8, 7, 7, 6}, /* 1965 */
178
{4, 6, 5, 6, 6, 7, 8, 8, 9, 8, 7, 6}, /* 1966 */
179
{4, 6, 5, 6, 6, 8, 8, 8, 9, 8, 8, 6}, /* 1967 */
180
{5, 5, 5, 5, 5, 7, 7, 7, 8, 7, 7, 5}, /* 1968 */
181
{4, 6, 5, 6, 6, 7, 8, 8, 8, 7, 7, 6}, /* 1969 */
182
{4, 6, 5, 6, 6, 7, 8, 8, 9, 8, 7, 6}, /* 1970 */
183
{4, 6, 5, 6, 6, 8, 8, 8, 9, 8, 8, 6}, /* 1971 */
184
{5, 5, 5, 5, 5, 7, 7, 7, 8, 7, 7, 5}, /* 1972 */
185
{4, 6, 5, 5, 6, 7, 8, 8, 8, 7, 7, 6}, /* 1973 */
186
{4, 6, 5, 6, 6, 7, 8, 8, 9, 8, 7, 6}, /* 1974 */
187
{4, 6, 5, 6, 6, 8, 8, 8, 9, 8, 8, 6}, /* 1975 */
188
{5, 5, 4, 5, 5, 7, 7, 7, 8, 7, 7, 5}, /* 1976 */
189
{4, 6, 5, 5, 6, 7, 7, 8, 8, 7, 7, 6}, /* 1977 */
190
{4, 6, 5, 6, 6, 7, 8, 8, 8, 8, 7, 6}, /* 1978 */
191
{4, 6, 5, 6, 6, 8, 8, 8, 9, 8, 8, 6}, /* 1979 */
192
{5, 5, 4, 5, 5, 7, 7, 7, 8, 7, 7, 5}, /* 1980 */
193
{4, 6, 5, 5, 6, 7, 7, 8, 8, 7, 7, 6}, /* 1981 */
194
{4, 6, 5, 6, 6, 7, 8, 8, 8, 8, 7, 6}, /* 1982 */
195
{4, 6, 5, 6, 6, 8, 8, 8, 9, 8, 8, 6}, /* 1983 */
196
{4, 5, 4, 5, 5, 7, 7, 7, 8, 7, 7, 5}, /* 1984 */
197
{5, 5, 5, 5, 5, 8, 7, 7, 8, 7, 7, 5}, /* 1985 */
198
{4, 6, 5, 6, 6, 7, 8, 8, 8, 8, 7, 6}, /* 1986 */
199
{4, 6, 5, 6, 6, 7, 8, 8, 9, 8, 7, 6}, /* 1987 */
200
{4, 5, 4, 5, 5, 7, 7, 7, 8, 7, 7, 5}, /* 1988 */
201
{5, 5, 5, 5, 5, 7, 7, 7, 8, 7, 7, 5}, /* 1989 */
202
{4, 6, 5, 6, 6, 7, 8, 8, 8, 8, 7, 6}, /* 1990 */
203
{4, 6, 5, 6, 6, 7, 8, 8, 9, 8, 7, 6}, /* 1991 */
204
{4, 5, 4, 5, 5, 7, 7, 7, 8, 7, 7, 5}, /* 1992 */
205
{5, 5, 5, 5, 5, 7, 7, 7, 8, 7, 7, 5}, /* 1993 */
206
{4, 6, 5, 6, 6, 7, 8, 8, 8, 7, 7, 6}, /* 1994 */
207
{4, 6, 5, 6, 6, 7, 8, 8, 9, 8, 7, 6}, /* 1995 */
208
{4, 5, 4, 5, 5, 7, 7, 7, 8, 7, 7, 5}, /* 1996 */
209
{5, 5, 4, 5, 5, 7, 7, 7, 8, 7, 7, 5}, /* 1997 */
210
{4, 6, 5, 6, 6, 7, 8, 8, 8, 7, 7, 6}, /* 1998 */
211
{4, 6, 5, 6, 6, 7, 8, 8, 9, 8, 7, 6}, /* 1999 */
212
{4, 5, 4, 5, 5, 7, 7, 7, 8, 7, 7, 5}, /* 2000 */
213
{4, 5, 5, 5, 5, 7, 7, 7, 8, 7, 7, 5}, /* 2001 */
214
{4, 6, 5, 6, 6, 7, 8, 8, 8, 7, 7, 6}, /* 2002 */
215
{4, 6, 5, 6, 6, 7, 8, 8, 9, 8, 7, 6}, /* 2003 */
216
{4, 5, 4, 5, 5, 7, 7, 7, 8, 7, 7, 5}, /* 2004 */
217
{4, 5, 5, 5, 5, 7, 7, 7, 8, 7, 7, 5}, /* 2005 */
218
{4, 6, 5, 5, 6, 7, 7, 8, 8, 7, 7, 6}, /* 2006 */
219
{4, 6, 5, 6, 6, 7, 8, 8, 9, 8, 7, 6}, /* 2007 */
220
{4, 5, 4, 5, 5, 7, 7, 7, 8, 7, 7, 5}, /* 2008 */
221
{4, 5, 4, 5, 5, 7, 7, 7, 8, 7, 7, 5}, /* 2009 */
222
{4, 6, 5, 5, 6, 7, 7, 8, 8, 7, 7, 6}, /* 2010 */
223
{4, 6, 5, 6, 6, 7, 8, 8, 8, 8, 7, 6}, /* 2011 */
224
{4, 5, 4, 5, 5, 7, 7, 7, 8, 7, 7, 5}, /* 2012 */
225
{4, 5, 4, 5, 5, 7, 7, 7, 8, 7, 7, 5}, /* 2013 */
226
{4, 6, 5, 5, 6, 7, 7, 8, 8, 7, 7, 6}, /* 2014 */
227
{4, 6, 5, 6, 6, 7, 8, 8, 8, 8, 7, 6}, /* 2015 */
228
{4, 5, 4, 5, 5, 7, 7, 7, 8, 7, 7, 5}, /* 2016 */
229
{3, 5, 4, 5, 5, 7, 7, 7, 8, 7, 7, 5}, /* 2017 */
230
{4, 5, 5, 5, 6, 7, 7, 8, 8, 7, 7, 5}, /* 2018 */
231
{4, 6, 5, 6, 6, 7, 8, 8, 8, 8, 7, 6}, /* 2019 */
232
{4, 5, 4, 5, 5, 6, 7, 7, 8, 7, 7, 5}, /* 2020 */
233
{3, 5, 4, 5, 5, 7, 7, 7, 8, 7, 7, 5}, /* 2021 */
234
{4, 5, 5, 5, 6, 7, 7, 7, 8, 7, 7, 5}, /* 2022 */
235
{4, 6, 5, 6, 6, 7, 8, 8, 8, 8, 7, 6}, /* 2023 */
236
{4, 5, 4, 5, 5, 6, 7, 7, 8, 7, 6, 5}, /* 2024 */
237
{3, 5, 4, 5, 5, 7, 7, 7, 8, 7, 7, 5}, /* 2025 */
238
{4, 5, 5, 5, 5, 7, 7, 7, 8, 7, 7, 5}, /* 2026 */
239
{4, 6, 5, 6, 6, 7, 8, 8, 8, 7, 7, 6}, /* 2027 */
240
{4, 5, 4, 5, 5, 6, 7, 7, 8, 7, 6, 5}, /* 2028 */
241
{3, 5, 4, 5, 5, 7, 7, 7, 8, 7, 7, 5}, /* 2029 */
242
{4, 5, 5, 5, 5, 7, 7, 7, 8, 7, 7, 5}, /* 2030 */
243
{4, 6, 5, 6, 6, 7, 8, 8, 8, 7, 7, 6}, /* 2031 */
244
{4, 5, 4, 5, 5, 6, 7, 7, 8, 7, 6, 5}, /* 2032 */
245
{3, 5, 4, 5, 5, 7, 7, 7, 8, 7, 7, 5}, /* 2033 */
246
{4, 5, 5, 5, 5, 7, 7, 7, 8, 7, 7, 5}, /* 2034 */
247
{4, 6, 5, 5, 6, 7, 7, 8, 8, 7, 7, 6}, /* 2035 */
248
{4, 5, 4, 5, 5, 6, 7, 7, 8, 7, 6, 5}, /* 2036 */
249
{3, 5, 4, 5, 5, 7, 7, 7, 8, 7, 7, 5}, /* 2037 */
250
{4, 5, 5, 5, 5, 7, 7, 7, 8, 7, 7, 5}, /* 2038 */
251
{4, 6, 5, 5, 6, 7, 7, 8, 8, 7, 7, 6}, /* 2039 */
252
{4, 5, 4, 5, 5, 6, 7, 7, 8, 7, 6, 5}, /* 2040 */
253
{3, 5, 4, 5, 5, 7, 7, 7, 8, 7, 7, 5}, /* 2041 */
254
{4, 5, 4, 5, 5, 7, 7, 7, 8, 7, 7, 5}, /* 2042 */
255
{4, 6, 5, 5, 6, 7, 7, 8, 8, 7, 7, 6}, /* 2043 */
256
{4, 5, 4, 5, 5, 6, 7, 7, 7, 7, 6, 5}, /* 2044 */
257
{3, 5, 4, 5, 5, 7, 7, 7, 8, 7, 7, 5}, /* 2045 */
258
{4, 5, 4, 5, 5, 7, 7, 7, 8, 7, 7, 5}, /* 2046 */
259
{4, 6, 5, 5, 6, 7, 7, 8, 8, 7, 7, 6}, /* 2047 */
260
{4, 5, 4, 5, 5, 6, 7, 7, 7, 7, 6, 5}, /* 2048 */
261
{3, 5, 4, 5, 5, 6, 7, 7, 8, 7, 7, 5} /* 2049 */