Browse Source

* Better precision for samedatetime. Issue ID #39023, patch by Zoran Vučenović

git-svn-id: trunk@49517 -
michael 4 years ago
parent
commit
492a0ffcac
1 changed files with 14 additions and 1 deletions
  1. 14 1
      packages/rtl-objpas/src/inc/dateutil.inc

+ 14 - 1
packages/rtl-objpas/src/inc/dateutil.inc

@@ -2060,8 +2060,21 @@ end;
 
 
 Function SameDateTime(const A, B: TDateTime): Boolean;
+
+  function MS(X: Double): Int64;
+  begin
+    if X >= 0 then
+      X := X * MSecsPerDay + 0.5
+    else if X > -1.0 then
+      X := -X * MSecsPerDay + 0.5
+    else
+      X := X * MSecsPerDay - 0.5;
+
+    Result := Trunc(X);
+  end;
+
 begin
-  Result:=Abs(A-B)<OneMilliSecond;
+  Result := MS(A) = MS(B);
 end;