Einzelnen Beitrag anzeigen

Benutzerbild von APP
APP

Registriert seit: 24. Feb 2003
Ort: Graz (A)
705 Beiträge
 
Delphi 7 Enterprise
 
#2

Re: Datum und Uhrzeit der Kompilierung (Compile Date Time)

  Alt 14. Mär 2004, 13:01
Hallo,

leider vergaß ich zu erwähnen, dass UnixToDateTime erst ab Delphi 6 und höher in der Unit "DateUtils.pas" vorhanden ist.

Rudy Velthuis (TeamB) hat aber eine allgemeine Lösung dafür:

Code:
If you have D6, look at the DateUtils functions:

  function DateTimeToUnix(const AValue: TDateTime): Int64;
  function UnixToDateTime(const AValue: Int64): TDateTime;

You can do them yourself. Unix time is seconds since Jan 1, 1970.
Compile a little test function:
 
  function Jan_1_1970: TDateTime;
  begin
    Result := EncodeDate(1970, 1, 1);
  end;

It seems that Jan_1_1970 returns 25569.0, so:

  function UnixToDateTime(Unix: Int64): TDateTime;
  begin
    Result := 25569.0 + Unix / SecsPerDay;
  end;

And vice versa:

  function DateTimeToUnix(DT: TDateTime): Int64;
  begin
    Result := Trunc(SecsPerDay * (DT - 25569.0));
  end;
Quelle: http://homepages.borland.com/efg2lab.../2002/0303.txt
Armin P. Pressler

BEGIN
...real programmers are using C/C++ - smart developers Delphi;
END;
  Mit Zitat antworten Zitat