p; end else begin iMonth:=12; iDay:=Word(iSpanDays)-18; end; Exit; end; //下面从阴历1901年正月初一算起 iSpanDays:=iSpanDays-49; iYear:=START_YEAR; iMonth:=1; iDay:=1; //计算年 tmp:=LunarYearDays(iYear); while iSpanDays>=tmp do begin iSpanDays:=iSpanDays-tmp; Inc(iYear); tmp:=LunarYearDays(iYear); end; //计算月 tmp:=LoWord(LunarMonthDays(iYear,iMonth)); while iSpanDays>=tmp do begin iSpanDays:=iSpanDays-tmp; if iMonth=GetLeapMonth(iYear) then begin tmp:=HiWord(LunarMonthDays(iYear,iMonth)); if iSpanDays<tmp then Break; iSpanDays:=iSpanDays-tmp; end; Inc(iMonth); tmp:=LoWord(LunarMonthDays(iYear,iMonth)); end; //计算日 iDay:=iDay+Word(iSpanDays); end;
function l_GetLunarHolDay(iYear,iMonth,iDay:Word):Word; var Flag:Byte; Day:Word; begin Flag:=gLunarHolDay[(iYear-START_YEAR)*12+iMonth-1]; if iDay<15 then Day:=15-((Flag shr 4) and $0f) else Day:=(Flag and $0f)+15; if iDay=Day then if iDay>15 then Result:=(iMonth-1)*2+2 else Result:=(iMonth-1)*2+1 else Result:= 0; end;
function GetLunarHolDay(InDate:TDateTime):string; var i,iYear,iMonth,iDay:Word; begin DecodeDate(InDate,iYear,iMonth,iDay); i:=l_GetLunarHolDay(iYear,iMonth,iDay); case i of 1:Result:=''''小 寒''''; 2:Result:=''''大 寒''''; 3:Result:=''''立 春''''; 4:Result:=''''雨 水''''; 5:Result:=''''惊 蛰''''; 6:Result:=''''春 分''''; 7:Result:=''''清 明''''; 8:Result:=''''谷 雨''''; 9:Result:=''''立 夏''''; 10:Result:=''''小 满''''; 11:Result:=''''芒 种''''; 12:Result:=''''夏 至''''; 13:Result:=''''小 暑''''; 14:Result:=''''大 暑''''; 15:Result:=''''立 秋''''; 16:Result:=''''处 暑''''; 17:Result:=''''白 露''''; 18:Result:=''''秋 分''''; 19:Result:=''''寒 露''''; 20:Result:=''''霜 降''''; 21:Result:=''''立 冬''''; 22:Result:=''''小 雪''''; 23:Result:=''''大 雪''''; 24:Result:=''''冬 至''''; else l_CalcLunarDate(iYear,iMonth,iDay,CalcDateDiff(InDate,EncodeDate(START_YEAR,1,1))); Result := trim(FormatMonth(iMonth) + FormatLunarDay(iDay)); end; end;
function GetLunarHolDay(iYear,iMonth,iDay:Word):string; begin Result:=GetLunarHolDay(EncodeDate(iYear,iMonth,iDay)); end; end.
上一页 [1] [2] [3] [4] [5] |