Răsfoiți Sursa

* Changed DateTimeToTimestamp not to use Round()

git-svn-id: trunk@23337 -
michael 12 ani în urmă
părinte
comite
7c8fcb63b7
1 a modificat fișierele cu 6 adăugiri și 3 ștergeri
  1. 6 3
      rtl/objpas/sysutils/dati.inc

+ 6 - 3
rtl/objpas/sysutils/dati.inc

@@ -55,11 +55,14 @@ function DateTimeToTimeStamp(DateTime: TDateTime): TTimeStamp;
 
 
 Var
 Var
   D : Double;
   D : Double;
-
 begin
 begin
   D:=DateTime * Single(MSecsPerDay);
   D:=DateTime * Single(MSecsPerDay);
-  result.Time := Abs(Round(D)) Mod MSecsPerDay;
-  result.Date := DateDelta + Round(D) div MSecsPerDay;
+  if D<0 then
+    D:=D-0.5
+  else
+    D:=D+0.5;
+  result.Time := Abs(Trunc(D)) Mod MSecsPerDay;
+  result.Date := DateDelta + Trunc(D) div MSecsPerDay;
 end;
 end;
 
 
 {   TimeStampToDateTime converts TimeStamp to a TDateTime value   }
 {   TimeStampToDateTime converts TimeStamp to a TDateTime value   }