Delphi 計算儒略日(Julian day)的代碼

將開發過程中比較好的一些內容做個備份,下面內容段是關於Delphi 計算儒略日(Julian day)的內容,應該對大夥也有用途。

function julday(year,month,day:integer;hour:double;gregflag:integer):Double;

var

  jd:double;

  u,u0,u1,u2:double;

begin

  u:=year;

  if (month < 3) then

   u:=u-1;

  u0:= u + 4712.0;

  u1:= month + 1.0;

  if (u1 < 4) then u1:=u1+12.0;

  if gregflag = SE_GREG_CAL then

  begin

    u2:= floor(abs(u) / 100) - floor(abs(u) / 400);

    if (u < 0.0) then u2:=-u2;

    jd:= jd - u2 + 2;

    if ((u < 0.0) and (u/100 = floor(u/100)) and (u/400 <> floor(u/400))) then

      jd :=jd-1;

  end;

  result:=jd;

end;
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章