?? datecn.pas
字號:
Var
i: integer;
DateStr: String;
Begin
DateStr := FormatDateTime('yyyy/mm/dd', Date);
i := length(inttostr(month(date)));
Case (StrToInt(Copy(DateStr, 1, 4)) - StrToInt(BaseSkyStemDate))
Mod 10 Of
0:
If (StrToInt(Copy(DateStr, 6, i)) < 4) And ((Pos('臘',
CnMonthOfDate(Date)) = 0) And (Pos('冬', CnMonthOfDate(Date)) = 0)) Then
Result := '甲'
Else
Begin
If StrToInt(Copy(DateStr, 6, i)) < 4 Then
Result := '癸'
Else
Result := '甲';
End;
1, -9:
If (StrToInt(Copy(DateStr, 6, i)) < 4) And ((Pos('臘',
CnMonthOfDate(Date)) = 0) And (Pos('冬', CnMonthOfDate(Date)) = 0)) Then
Result := '乙'
Else
Begin
If StrToInt(Copy(DateStr, 6, i)) < 4 Then
Result := '甲'
Else
Result := '乙';
End;
2, -8:
If (StrToInt(Copy(DateStr, 6, i)) < 4) And ((Pos('臘',
CnMonthOfDate(Date)) = 0) And (Pos('冬', CnMonthOfDate(Date)) = 0)) Then
Result := '丙'
Else
Begin
If StrToInt(Copy(DateStr, 6, i)) < 4 Then
Result := '乙'
Else
Result := '丙';
End;
3, -7:
If (StrToInt(Copy(DateStr, 6, i)) < 4) And ((Pos('臘',
CnMonthOfDate(Date)) = 0) And (Pos('冬', CnMonthOfDate(Date)) = 0)) Then
Result := '丁'
Else
Begin
If StrToInt(Copy(DateStr, 6, i)) < 4 Then
Result := '丙'
Else
Result := '丁';
End;
4, -6:
If (StrToInt(Copy(DateStr, 6, i)) < 4) And ((Pos('臘',
CnMonthOfDate(Date)) = 0) And (Pos('冬', CnMonthOfDate(Date)) = 0)) Then
Result := '戊'
Else
Begin
If StrToInt(Copy(DateStr, 6, i)) < 4 Then
Result := '丁'
Else
Result := '戊';
End;
5, -5:
If (StrToInt(Copy(DateStr, 6, i)) < 4) And ((Pos('臘',
CnMonthOfDate(Date)) = 0) And (Pos('冬', CnMonthOfDate(Date)) = 0)) Then
Result := '巳'
Else
Begin
If StrToInt(Copy(DateStr, 6, i)) < 4 Then
Result := '戊'
Else
Result := '巳';
End;
6, -4:
If (StrToInt(Copy(DateStr, 6, i)) < 4) And ((Pos('臘',
CnMonthOfDate(Date)) = 0) And (Pos('冬', CnMonthOfDate(Date)) = 0)) Then
Result := '庚'
Else
Begin
If StrToInt(Copy(DateStr, 6, i)) < 4 Then
Result := '巳'
Else
Result := '庚';
End;
7, -3:
If (StrToInt(Copy(DateStr, 6, i)) < 4) And ((Pos('臘',
CnMonthOfDate(Date)) = 0) And (Pos('冬', CnMonthOfDate(Date)) = 0)) Then
Result := '辛'
Else
Begin
If StrToInt(Copy(DateStr, 6, i)) < 4 Then
Result := '庚'
Else
Result := '辛';
End;
8, -2:
If (StrToInt(Copy(DateStr, 6, i)) < 4) And ((Pos('臘',
CnMonthOfDate(Date)) = 0) And (Pos('冬', CnMonthOfDate(Date)) = 0)) Then
Result := '壬'
Else
Begin
If StrToInt(Copy(DateStr, 6, i)) < 4 Then
Result := '辛'
Else
Result := '壬';
End;
9, -1:
If (StrToInt(Copy(DateStr, 6, i)) < 4) And ((Pos('臘',
CnMonthOfDate(Date)) = 0) And (Pos('冬', CnMonthOfDate(Date)) = 0)) Then
Result := '癸'
Else
Begin
If StrToInt(Copy(DateStr, 6, i)) < 4 Then
Result := '壬'
Else
Result := '癸';
End;
End;
Result := Result + Copy(CnanimalOfYear(Date), 1, 3);
End;
Function CnSolarTerm(Date: TDate): String; //返回十大天干
Var
Year, Month, Day, Hour: Word;
Begin
DecodeDate(Date, Year, Month, Day);
// d:=( ( 31556925974.7*(Year-1900) + SolarTerm[Month]*60000) + Date(1900,0,6,2,5) );
End;
Function GetLunarHolDay(InDate: TDateTime; Days: Integer): String;
Var
Year, Month, Day, Hour: Word;
Begin
DecodeDate(Date, Year, Month, Day);
Result := GetLunarHolDay(EncodeDate(Year, Month, Days));
End;
Function GetLunarHolDay(InDate: TDateTime): String;
Var
i, iYear, iMonth, iDay: Word;
Begin
// InDate := StrToDate(FormatDateTime('yyyy/mm/dd', InDate));
Result := '';
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 := '冬至';
End;
End;
Function l_GetLunarHolDay(iYear, iMonth, iDay: Word): Word;
Var
Flag: Byte;
Day: Word;
Begin
// var offDate = new Date( ( 31556925974.7*(y-1900) + sTermInfo[n]*60000 ) + Date.UTC(1900,0,6,2,5) )
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 OtherHoliday(Month, Day: integer): String;
Begin
//五月的第二個星期日慶祝母親節(jié)
//將每年6月的第3個星期天定為父親節(jié) ?
{
新年元旦[01/01] 臘八節(jié)[農(nóng)歷十二月初八]
世界濕地日[02/02] 國際氣象節(jié)[02/10] 情人節(jié)[02/14]
除夕[農(nóng)歷十二月三十] 春節(jié)[農(nóng)歷正月初一] 元宵節(jié)[農(nóng)歷正月十五]
全國愛耳日[03/03] 婦女節(jié)[03/08] 植樹節(jié)[03/12]
國際警察日[03/14] 國際消費日[03/15] 世界森林日[03/21]
世界水日[03/22] 世界氣象日[03/23] 世界防治結(jié)核病日[03/24]
愚人節(jié)[04/01] 清明[04/05] 世界衛(wèi)生日[04/07]
世界地球日[04/22]
國際勞動節(jié)[05/01] 中國青年節(jié)[05/04] 全國碘缺乏病日[05/05]
世界紅十字日[05/08] 國際護(hù)士節(jié)[05/12] 國際家庭日[05/15]
世界電信日[05/17] 國際博物館日[05/18] 全國助殘日[05/19]
全國學(xué)生營養(yǎng)日[05/20] 國際生物多樣性日[05/22] 國際牛奶日[05/23]
世界無煙日[05/31] 端午節(jié)[農(nóng)歷五月初五] 母親節(jié)[第二個星期日]
國際兒童節(jié)[06/01] 世界環(huán)境日[06/05] 全國愛眼日[06/06]
端午節(jié)[06/15] 父親節(jié)[第三個星期日] 防治荒漠化和干旱日[06/17]
國際奧林匹克日[06/23] 全國土地日[06/25] 國際反毒品日[06/26]
香港回歸日[07/01] 七夕情人節(jié)[農(nóng)歷七月初七] 建黨日[07/01]
中國人民抗日戰(zhàn)爭紀(jì)念日[07/07] 世界人口日[07/11]
八一建軍節(jié)[08/01]
勞動節(jié)[09/02] 國際掃盲日[09/08] 教師節(jié)[09/10]
國際臭氧層保護(hù)日[09/16] 國際和平日[09/17] 國際愛牙日[09/20]
中秋節(jié)[農(nóng)歷八月十五] 國際聾人節(jié)[09/22] 世界旅游日[09/27]
重陽節(jié)[農(nóng)歷九月九日]
國慶節(jié)[10/01] 國際音樂節(jié)[10/01] 國際減輕自然災(zāi)害日[10/02]
世界動物日[10/04] 國際住房日[10/07] 全國高血壓日[10/08]
世界視覺日[10/08] 世界郵政日[10/09] 世界精神衛(wèi)生日[10/10]
國際盲人節(jié)[10/15] 世界糧食節(jié)[10/16] 世界消除貧困日[10/17]
世界傳統(tǒng)醫(yī)藥日[10/22] 聯(lián)合國日[10/24] 萬圣節(jié)[10/31]
中國記者日[11/08] 消防宣傳日[11/09] 世界糖尿病日[11/14]
國際大學(xué)生節(jié)[11/17] 感恩節(jié)[11/28]
冬至節(jié)[農(nóng)歷12月22日] 世界艾滋病日[12/01] 世界殘疾人日[12/03]
世界足球日[12/09] 圣誕節(jié)[12/25]
}
result := '';
Case Month Of
1:
Begin
End;
2:
Begin
If day = 2 Then
result := '濕地日';
If day = 10 Then
result := '氣象節(jié)';
End;
3:
Begin
If day = 3 Then
result := '愛耳日';
If day = 12 Then
result := '植樹節(jié)';
If day = 14 Then
result := '警察日';
If day = 15 Then
result := '消費節(jié)';
If day = 21 Then
result := '森林日';
If day = 22 Then
result := '水日';
If day = 23 Then
result := '氣象日';
End;
4:
Begin
If day = 7 Then
result := '衛(wèi)生日';
If day = 22 Then
result := '地球日';
End;
5:
Begin
If day = 8 Then
result := '紅十字';
If day = 12 Then
result := '護(hù)士節(jié)';
If day = 15 Then
result := '家庭日';
If day = 17 Then
result := '電信日';
If day = 18 Then
result := '博物館';
If day = 19 Then
result := '助殘日';
If day = 23 Then
result := '牛奶日';
If day = 31 Then
result := '無煙日';
// 母親節(jié)[第二個星期日]
End;
6:
Begin
If day = 5 Then
result := '環(huán)境日';
If day = 6 Then
result := '愛眼日';
If day = 23 Then
result := '體育日';
If day = 25 Then
result := '土地日';
If day = 26 Then
result := '反毒品';
// 父親節(jié)[第三個星期日]
End;
7:
Begin
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -