Einzelnen Beitrag anzeigen

Benutzerbild von Wolfgang Mix
Wolfgang Mix

Registriert seit: 13. Mai 2009
Ort: Lübeck
1.222 Beiträge
 
Delphi 2005 Personal
 
#1

TDate für negative Jahreszahlen?

  Alt 19. Aug 2009, 19:03
Habe gerade das Julianische Datum aus Wikepedia nach Delphi übersetzt,
würde als Rückgabewert gerne TDate statt String haben. Geht das irgendwie für negative Jahre?
Delphi macht meines Wissens bei Datum < 1.1.0001 schlapp.


Delphi-Quellcode:
implementation

{$R *.dfm}

function test(jd:longint):String;
var day,month,year:word;
    greg:longint;
    A,Alpha,B,C,D,E,F,G,J,M,T,Z:real;
{Eingabe:       JD   (Julianischer Tag) }
begin
  Z:=Int (JD + 0.5);
  F:=Frac(JD + 0.5);

  If Z < 2299161 Then A:=Z // 15.10.1582
  else
  begin
   g:= int((Z-1867216.25) / 36525.25);
   a:=z+1+g-int(g/4);
  end;
  B := A+1524;
  C := Int((B-122.1)/365.25);
  D := int(365.25 * C);
  E := Int((B-D)/30.6001);
  T := B-D-int(30.6001*E) + F;
  if(E<14) then
    M := E-1
  else
    M := E-13;
  if (M>2) then
      J := C-4716
  else
      J := C-4715;
  if j<1 then j:=j-1;
  T:=trunc(T);
  result:=FloatToStr(T)+'.'+FloatToStr(M)+'.'+FloatToStr(J);
end;

//T.M.J = Kalenderdatum von JD


procedure TForm1.Button1Click(Sender: TObject);
var jd:longint;
begin
   edit1.Text:=test(0);
end;

end.
Gruß

Wolfgang
Wolfgang Mix
if you can't explain it simply you don't understand it well enough - A. Einstein
Mein Baby:http://www.epubli.de/shop/buch/Grund...41818516/52824
  Mit Zitat antworten Zitat