求《日索历》网络版源码,或者算二十四节气的方法。
{
int源;
int SolarYear
int SolarMonth
int SolarDate
阴历间;
阴历月间;
int LunarDate
int工作日;
int Kan
int Chih
};
unsigned _ _ int 64m _ ui 64 solar terms[24];
unsigned _ _ int 64m _ ui64 month days[13];
m _ ui64 month days[0]= 0ui 64;
m _ ui64 month days[1]= 31ui 64;
m _ ui64 month days[2]= 28ui 64;
m _ ui64 month days[3]= 31ui 64;
m _ ui64 month days[4]= 30ui 64;
m _ ui64 month days[5]= 31ui 64;
m _ ui64 month days[6]= 30ui 64;
m _ ui64 month days[7]= 31ui 64;
m _ ui64 month days[8]= 31ui 64;
m _ ui64 month days[9]= 30ui 64;
m _ ui64 month days[10]= 31ui 64;
m _ ui 64 month days[11]= 30ui 64;
m _ ui64 month days[12]= 31ui 64;
m _ ui 64 solarterms[0]= 0ui 64;
m _ ui 64 solarterms[1]= 21208 ui 64;
m _ ui 64 solarterms[2]= 42467 ui 64;
m _ ui 64 solarterms[3]= 63836 ui 64;
m _ ui 64 solarterms[4]= 85337 ui 64;
m _ ui 64 solarterms[5]= 107014ui 64;
m _ ui 64 solarterms[6]= 128867 ui 64;
m _ ui 64 solarterms[7]= 150921ui 64;
m _ ui 64 solarterms[8]= 173149 ui 64;
m _ ui 64 solarterms[9]= 195551ui 64;
m _ ui 64 solarterms[10]= 218072 ui 64;
m _ ui 64 solarterms[11]= 240693 ui 64;
m _ ui 64 solarterms[12]= 263343 ui 64;
m _ ui 64 solarterms[13]= 285989 ui 64;
m _ ui 64 solarterms[14]= 308563 ui 64;
m _ ui 64 solarterms[15]= 331033 ui 64;
m _ ui 64 solarterms[16]= 353350 ui 64;
m _ ui 64 solarterms[17]= 375494 ui 64;
m _ ui 64 solarterms[18]= 397447 ui 64;
m _ ui 64 solarterms[19]= 419210ui 64;
m _ ui 64 solarterms[20]= 440795 ui 64;
m _ ui 64 solarterms[21]= 462224 ui 64;
m _ ui 64 solarterms[22]= 483532 ui 64;
m _ ui 64 solarterms[23]= 504758 ui 64;
/* 24节气计算*/
int _ _ fast call is leapy year(int iYear)
{
如果((iYear & amp3) != 0)
{
返回0;
}
else if (iYear % 100!= 0)
{
返回1;
}
else if (iYear % 400 == 0)
{
返回1;
}
其他
{
返回0;
}
}
int _ _ fast call TheSolarTerm(int iYear,int n)
{
无符号_ _ int 64k;
unsigned _ _ int 64 ddate _ utc = 22085493000000 ui 64;
unsigned __int64 doffdate,dadddate
doff date = m _ ui 64 solarterms[n]* 600000 ui 64;
doff date+= static _ cast & lt;unsigned _ _ int64 & gt(iYear-1900)* 315569259747 ui 64;
doff date-= ddate _ utc;
doff date/= 864000000 ui 64;//86400: 60 * 60 * 24 * 1000
int I = 1969;
dadddate = 0ui64
while(dadddate & lt;doffdate)
{
i++;
k = dadddate
dadd date+= 365 ui 64+static _ cast & lt;unsigned _ _ int64 & gt(IsLeapYear(I));
};
if(dadddate & gt;doffdate)
{
int j = 0;
dadd date = k;
while(dadddate & lt;doffdate & amp& ampj & lt12)
{
j++;
k = dadddate
dadd date+= m _ ui 64 month days[j];
if(j = = 2 & amp;& amp(IsLeapYear(我)!= 0))
{
dadd date++;
}
};
返回static _ cast & ltint & gt(道夫日期-k+1ui 64);
}
else // j = doffdate
{
返回1;
}
}
int CalConv(struct ConvDate & amp;光盘)
{
int leap,d,sm,y,im,l1,l2,acc,I,lm,KC;
如果(cd。Source == 0) /* Solar */
{
如果(cd。SolarYear & lt=第一年|| cd。SolarYear & gt去年)
{
返回1;
}
sm = cd。solar month-1;
if(sm & lt;0 | | sm & gt11)
{
return 2;
}
leap = GetLeap(cd。solar year);
d = (sm == 1)?(闰+28):solar cal[sm];
如果(cd。SolarDate & lt1 || cd。SolarDate & gtd)
{
返回3;
}
y = cd。SolarYear -第一年;
acc = SolarDays[leap][sm] + cd。SolarDate
光盘。Weekday = (acc + LunarCal[y])。base weekday)% 7;
kc = acc + LunarCal[y]。BaseKanChih
光盘。Kan = KC % 10;
光盘。chih = KC % 12;
if(ACC & lt;= LunarCal[y]。基准日)
{
y-;
光盘。LunarYear = cd。solary ear-1;
leap = GetLeap(cd。lunar year);
sm+= 12;
acc = SolarDays[leap][sm] + cd。SolarDate
}
其他
{
光盘。LunarYear = cd。SolarYear
}
l1 = LunarCal[y]。基准日;
for(I = 0;我& lt13;i++)
{
l2 = l1 + LunarCal[y]。month days[I]+29;
if(ACC & lt;= l2)
{
打破;
}
l 1 = L2;
}
光盘。lunar month = I+1;
光盘。lunar date = ACC-l 1;
im = LunarCal[y]。插层;
如果(im!= 0 & amp& amp光盘。LunarMonth & gt即时消息)
{
光盘。lunar month-;
如果(cd。LunarMonth == im)
{
光盘。lunar month =-im;
}
}
如果(cd。LunarMonth & gt12)
{
光盘。lunar month-= 12;
}
}
else /* Lunar */
{
如果(cd。LunarYear & lt第一年|| cd。LunarYear & gt=去年)
{
返回1;
}
y = cd。农历新年-第一年;
im = LunarCal[y]。插层;
lm = cd。LunarMonth
if(lm & lt;0)
{
如果(lm!= -im)
{
return 2;
}
}
else if(lm & lt;1 | | lm & gt;12)
{
return 2;
}
如果(im!= 0)
{
if(lm & gt;即时消息)
{
lm++;
}
else if (lm == -im)
{
lm = im+1;
}
}
lm-;
如果(cd。LunarDate & gtLunarCal[y]。月天数[lm] + 29)
{
返回3;
}
acc = LunarCal[y]。基准日;
for(I = 0;我& ltlm;i++)
{
acc += LunarCal[y]。month days[I]+29;
}
acc += cd。LunarDate
leap = GetLeap(cd。lunar year);
for(I = 13;我& gt= 0;我-)
{
if(ACC & gt;solar days[闰][i])
{
打破;
}
}
光盘。solar date = ACC-solar days[leap][I];
如果(我& lt= 11)
{
光盘。SolarYear = cd。LunarYear
光盘。solar month = I+1;
}
其他
{
光盘。SolarYear = cd。lunar year+1;
光盘。solar month = I-11;
}
leap = GetLeap(cd。solar year);
y = cd。SolarYear -第一年;
acc = SolarDays[leap][cd。SolarMonth - 1] + cd。SolarDate
光盘。Weekday = (acc + LunarCal[y])。base weekday)% 7;
kc = acc + LunarCal[y]。BaseKanChih
光盘。Kan = KC % 10;
光盘。chih = KC % 12;
}
返回0;
}