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;

猜你喜欢

转载自blog.51cto.com/14118518/2347822