打印本文 打印本文 关闭窗口 关闭窗口
日历函数单元
作者:武汉SEO闵涛  文章来源:敏韬网  点击数3120  更新时间:2009/4/23 18:26:14  文章录入:mintao  责任编辑:mintao
h));
  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
    Result := '''''''';
  end;
end;

function GetLunarHolDay(iYear, iMonth, iDay: Word): string;
begin
  Result := GetLunarHolDay(EncodeDate(iYear, iMonth, iDay));
end;

function GetConstellation(const DateTime: TDateTime): Integer;
var
  Y, M, D: Word;
begin
  DecodeDate(DateTime, Y, M, D);
  Y := M * 100 + D;
  if (Y >= 321) and (Y <= 419) then
    Result := 0
  else
    if (Y >= 420) and (Y <= 520) then
      Result := 1
    else
      if (Y >= 521) and (Y <= 620) then
        Result := 2
      else
        if (Y >= 621) and (Y <= 722) then
          Result := 3
        else
          if (Y >= 723) and (Y <= 822) then
            Result := 4
          else
            if (Y >= 823) and (Y <= 922) then
              Result := 5
            else
              if (Y >= 923) and (Y <= 1022) then
                Result := 6
              else
                if (Y >= 1023) and (Y <= 1121) then
                  Result := 7
                else
                  if (Y >= 1122) and (Y <= 1221) then
                    Result := 8
                  else
                    if (Y >= 1222) or (Y <= 119) then
                      Result := 9
                    else
                      if (Y >= 120) and (Y <= 218) then
                        Result := 10
                      else
                        if (Y >= 219) and (Y <= 320) then
                          Result := 11
                        else
                          Result := -1;
end;

function GetConstellationName(const Constellation: Integer): string;
begin
  case Constellation of
    0: Result := ''''白羊座'''';
    1: Result := ''''金牛座'''';
    2: Result := ''''双子座'''';
    3: Result := ''''巨蟹座'''';
    4: Result := ''''狮子座'''';
    5: Result := ''''处女座'''';
    6: Result := ''''天秤座'''';
    7: Result := ''''天蝎座'''';
    8: Result := ''''射手座'''';
    9: Result := ''''摩羯座'''';
    10: Result := ''''水瓶座'''';
    11: Result := ''''双鱼座'''';
  else
    Result := '''''''';
  end;
end;

function GetConstellationName(const DateTime: TDateTime): string;
begin
  Result := GetConstellationName(GetConstellation(DateTime));
end;

end.

上一页  [1] [2] [3] [4] 

打印本文 打印本文 关闭窗口 关闭窗口