黄历日所

结构转换日期

{

int Source

int SolarYear

int SolarMonth

int SolarDate

阴历间;

月际;

月际;

int Weekday

int Kan

int Chih

};

unsigned _ _ int 64m _ ui 64 solarterms【24】;

unsigned _ _ int 64m _ ui 64 month days【13】;

m _ ui64 month days【0】= 0ui 64;

m _ ui 64 month days【1】= 31ui 64;

m _ ui 64 month days【2】= 28ui 64;

m _ ui 64 month days【3】= 31ui 64;

m _ ui 64 month days【4】= 30ui 64;

m _ ui 64 month days【5】= 31ui 64;

m _ ui 64 month days【6】= 30ui 64;

m _ ui 64 month days【7】= 31ui 64;

m _ ui 64 month days【8】= 31ui 64;

m _ ui 64 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;

/*二十四节气计算*/

int _ _ fastcall is leapy year(int iYear)

{

if((iYear & amp;3) != 0)

{

返回0;

}

else if(iYear % 100!= 0)

{

返回1;

}

else if(iYear % 400 = = 0)

{

返回1;

}

其他

{

返回0;

}

}

int _ _ fastcall TheSolarTerm(int iYear,int n)

{

unsigned _ _ int 64k;

unsigned _ _ int 64 ddate _ utc = 22085493000000 ui 64;

unsigned __int64 doffdate,dadddate

doff date = m _ ui 64 solarterms【n】* 600000 ui 64;

doffdate+= static _ cast & lt;未签名_ _ int64 & gt(iYear-1900)* 315569259747 ui 64;

doffdate-= ddate _ utc;

doff date/= 864000000 ui 64;//86400: 60 * 60 * 24 * 1000

int I = 1969;

dadddate = 0ui64

while(dadddate & lt;道夫日期)

{

i++;

k = dadddate

dadddate+= 365 ui 64+static _ cast & lt;未签名_ _ int64 & gt(IsLeapYear(I));

};

if(dadddate & gt;道夫日期)

{

int j = 0;

dadddate = k;

while(dadddate & lt;道夫日期& amp& ampj & lt12)

{

j++;

k = dadddate

dadddate+= m _ ui 64 month days【j】;

if(j = = 2 & amp;& amp(IsLeapYear(I)!= 0))

{

dadddate ++;

}

};

返回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)

{

返回2;

}

leap = get leap(CD。solar year);

d =(sm = = 1)?(闰+28):solar cal【sm】;

如果(cd。SolarDate & lt1 || cd。SolarDate & gtd)

{

返回3;

}

y = cd。太阳能-第一年;

ACC = solar days【leap】【sm】+CD。SolarDate

光盘。weekday =(ACC+lunar cal【y】。base weekday)% 7;

KC = ACC+lunar cal【y】。BaseKanChih

光盘。Kan = KC % 10;

光盘。chih = KC % 12;

if(ACC & lt;= lunar cal【y】。基准日)

{

y-;

光盘。LunarYear = cd。solar year-1;

leap = get leap(CD。lunar year);

sm+= 12;

ACC = solar days【leap】【sm】+CD。SolarDate

}

其他

{

光盘。LunarYear = cd。SolarYear

}

l 1 = lunar cal【y】。基准日;

for(I = 0;我& lt13;i++)

{

L2 = l 1+lunar cal【y】。month days【I】+29;

if(ACC & lt;= l2)

{

打破;

}

l 1 = L2;

}

光盘。lunar month = I+1;

光盘。lunar date = ACC-l 1;

im = lunar cal【y】。插层;

如果(im!= 0 & amp& amp光盘。新月& gtim)

{

光盘。lunar month-;

如果(cd。LunarMonth == im)

{

光盘。lunar month =-im;

}

}

如果(cd。新月& gt12)

{

光盘。lunar month-= 12;

}

}

else /* Lunar */

{

如果(cd。LunarYear & lt第一年||光盘。LunarYear & gt=去年)

{

返回1;

}

y = cd。农历新年-第一年;

im = lunar cal【y】。插层;

lm = cd。LunarMonth

if(lm & lt;0)

{

如果(lm!= -im)

{

返回2;

}

}

else if(lm & lt;1 | | lm & gt;12)

{

返回2;

}

如果(im!= 0)

{

if(lm & gt;im)

{

lm++;

}

else if(lm = =-im)

{

lm = im+1;

}

}

lm-;

如果(cd。LunarDate & gtlunar cal【y】月天数【lm】+29)

{

返回3;

}

ACC = lunar cal【y】。基准日;

for(I = 0;我& ltlm;i++)

{

ACC+= lunar cal【y】。month days【I】+29;

}

acc += cd。LunarDate

leap = get leap(CD。lunar year);

for(I = 13;我& gt= 0;我-)

{

if(ACC & gt;SolarDays【leap】【I】)

{

打破;

}

}

光盘。solar date = ACC-solar days【leap】【I】;

如果(i & lt= 11)

{

光盘。SolarYear = cd。LunarYear

光盘。solar month = I+1;

}

其他

{

光盘。SolarYear = cd。lunar year+1;

光盘。solar month = I-11;

}

leap = get leap(CD。solar year);

y = cd。太阳能-第一年;

ACC = solar days【leap】【CD。solar month-1】+CD。SolarDate

光盘。weekday =(ACC+lunar cal【y】。base weekday)% 7;

KC = ACC+lunar cal【y】。BaseKanChih

光盘。Kan = KC % 10;

光盘。chih = KC % 12;

}

返回0;

}