Einzelnen Beitrag anzeigen

Benutzerbild von Wolfgang Mix
Wolfgang Mix

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

Re: Gregorianischer Tag - Gregorianisches Datum

  Alt 23. Aug 2009, 14:14
Zur Ergänzung biete ich noch eine plattformunabhängige Variante, die ich aus fölgendem Link übersetzt habe:

http://mathforum.org/library/drmath/view/62338.html

Fehlerhafte Übergabewerte müßt Ihr dann je nach Programmiersprache selbst abfangen.

Gruß

Wolfgang

Delphi-Quellcode:
implementation

{$R *.dfm}

{Eingabe d,m,y
Ausgabe GD,  15.10.1582 gd = 1}

// Quelle: [url]http://mathforum.org/library/drmath/view/62338.html[/url]
function gd(d,m,y:real):longint;
var a,b,temp:real;
begin
  if (m=1) or (m=2) then
  begin
    y:=y-1;m:=m+13;
  end
  else m:=m+1;
  a:=int(y/100);
  b:=2 - a + int(a/4);
  temp:=int(int(365.25 * y) +int(30.6001*m) + b + d + 1720995);
  result:=trunc(temp);


end;


procedure TForm1.Button1Click(Sender: TObject);
var d,m,y:integer;
begin
  d:=StrToInt(spinedit1.text);
  m:=StrToInt(spinedit2.text);
  y:=StrToInt(spinedit3.text);
  edit1.Text:= IntToStr(gd(d,m,y));
end;

end.
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