Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   OOP (https://www.clubdelphi.com/foros/forumdisplay.php?f=5)
-   -   Calcula Dia Juliano a partir de fecha y hora (https://www.clubdelphi.com/foros/showthread.php?t=94600)

compuin 22-04-2020 13:58:33

Calcula Dia Juliano a partir de fecha y hora
 
Buenos dias foro,

Tengo una funcion para calcular el Dia Juliano, asi

Código Delphi [-]
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
Código Delphi [-]
'03-11-1972'
funciona correcto y me arroja
Código Delphi [-]
2441624.5000
.

El asunto esta cuando intento agregar la hora a la misma funcion, deberia arrojarme
Código Delphi [-]
2441624.8937
pero lo que me arroja es
Código Delphi [-]
0.72839208304
.

Aca la funcion que uso para calcular incluyendo horas

Código Delphi [-]
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:


Código Delphi [-]
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!!!


La franja horaria es GMT +2. Ahora son las 12:46:10.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi