PDA

Ver la Versión Completa : Calcula Dia Juliano a partir de fecha y hora


compuin
22-04-2020, 13:58:33
Buenos dias foro,

Tengo una funcion para calcular el Dia Juliano, asi

Function DateJulienne(annee, mois, jour :integer):real;
var
aj, ye,mm,dd : integer;
bj,jj,x : real;
begin
ye := annee;
mm := mois;
dd := jour;
x := annee + mois / 10 + jour / 10000;
IF (mm <= 2) THEN
begin
ye := ye - 1;
mm := mm + 12;
end;
IF (x > 1583.101512) then
begin
aj := ye DIV 100;
bj := 2 - aj + aj DIV 4;
end else bj := 0;
jj := trunc(365.25 * ye) + trunc(30.6001 * (mm + 1));
jj := jj + dd + 1720994.5 + bj ;
DateJulienne := (jj);
end;

Para esta fecha'03-11-1972' funciona correcto y me arroja 2441624.5000.

El asunto esta cuando intento agregar la hora a la misma funcion, deberia arrojarme 2441624.8937 pero lo que me arroja es 0.72839208304.

Aca la funcion que uso para calcular incluyendo horas

Function JourJulien(annee, mois, jour :integer; heure:real ):real;
var
aj,ye,mm,bj,dd : integer;
jj,x : real;
begin
ye := annee;
mm := mois;
dd := jour;
x := annee + mois / 10 + jour / 10000 + heure / 1000000;
IF (mm <= 2) THEN
begin
ye := ye - 1;
mm := mm + 12;
end;
IF (x > 1583.101512) then
begin
aj := ye DIV 100;
bj := 2 - aj + aj DIV 4;
end else bj := 0;
jj := trunc(365.25 * ye) + trunc(30.6001 * (mm + 1));
jj := jj + dd + 1720994.5 + bj + heure / 24;
JourJulien := (jj - 2415020) / 36525;
end; { JourJulien }

Que estoy calculando mal ?

escafandra
22-04-2020, 20:10:15
Es mejor usas DateTimeToJulianDate de delpfi, pero si quieres hacerlo con esa función que publicas puedes hacer esto:



function DateJulienne(annee, mois, jour :integer; h, m, s, ms: integer): real;
var
aj, ye,mm,dd : integer;
bj,jj,x, hh : real;
begin
ye := annee;
mm := mois;
dd := jour;
x := annee + mois / 10 + jour / 10000;
if mm <= 2 then
begin
ye := ye - 1;
mm := mm + 12;
end;
if x > 1583.101512 then
begin
aj := ye DIV 100;
bj := 2 - aj + aj DIV 4;
end else bj := 0;
jj := trunc(365.25 * ye) + trunc(30.6001 * (mm + 1));
jj := jj + dd + 1720994.5 + bj ;
hh := h + m/60 + s/3600 + ms/3600000;
hh := hh/24;
DateJulienne := (jj + hh);
end;




Saludos.

compuin
22-04-2020, 20:38:09
Muchas gracias amigo!!!