Browse Source

* fix for 037361 daysbetween if parameters are swapped and cross "0" boundery.

git-svn-id: trunk@45793 -
marco 5 years ago
parent
commit
3b60890373
1 changed files with 5 additions and 3 deletions
  1. 5 3
      packages/rtl-objpas/src/inc/dateutil.inc

+ 5 - 3
packages/rtl-objpas/src/inc/dateutil.inc

@@ -1390,9 +1390,11 @@ end;
 
 Function DaysBetween(const ANow, AThen: TDateTime): Integer;
 begin
-  Result:=Trunc(Abs(DateTimeDiff(ANow,AThen))+HalfMilliSecond);
-end;
-
+  if anow>athen then
+    Result:=Trunc(Abs(DateTimeDiff(ANow,AThen))+HalfMilliSecond)
+  else
+    Result:=Trunc(Abs(DateTimeDiff(AThen,ANow))+HalfMilliSecond); // bug 37361
+end;            
 
 Function HoursBetween(const ANow, AThen: TDateTime): Int64;
 begin