Einzelnen Beitrag anzeigen

Horst_

Registriert seit: 22. Jul 2004
Ort: Münster Osnabrück
116 Beiträge
 
#7

AW: CompareDateTime unter XE2 deutlich langsamer als D2009

  Alt 25. Apr 2012, 19:16
Hallo,

in freepascal läuft es so:
Delphi-Quellcode:
{dateih.inc}
const
   HoursPerDay = 24;
   MinsPerHour = 60;
   SecsPerMin = 60;
   MSecsPerSec = 1000;
   MinsPerDay = HoursPerDay * MinsPerHour;//1440
   SecsPerDay = MinsPerDay * SecsPerMin; //86400
   MSecsPerDay = SecsPerDay * MSecsPerSec; //86400000
..
{dateutil.inc}
const
  OneMillisecond = 1/MSecsPerDay;

Function SameDateTime(const A, B: TDateTime): Boolean;
begin
  Result:=Abs(A-B)<OneMilliSecond;
end;

Function CompareDateTime(const A, B: TDateTime): TValueRelationship;
begin
  If SameDateTime(A,B) then
    Result:=EqualsValue
  else If A>B then
    Result:=GreaterThanValue
  else
    Result:=LessThanValue
end;
Das wäre ja leicht zu testen, ob es so wieder schneller wäre

Gruß Horst
  Mit Zitat antworten Zitat