Parcourir la source

+ Fixed problems with DateTimes before 1899-12-29 (issue #6925)
+ fix for the datasize of strings

git-svn-id: trunk@3680 -

joost il y a 19 ans
Parent
commit
530ab18c2a
1 fichiers modifiés avec 6 ajouts et 2 suppressions
  1. 6 2
      fcl/db/sqldb/postgres/pqconnection.pp

+ 6 - 2
fcl/db/sqldb/postgres/pqconnection.pp

@@ -511,8 +511,8 @@ begin
 
       if (fieldtype = ftstring) and (size = -1) then
         begin
-        size := pqfmod(res,i)-3;
-        if size = -4 then size := dsMaxStringSize;
+        size := pqfmod(res,i)-4;
+        if size = -5 then size := dsMaxStringSize;
         end;
       if fieldtype = ftdate  then
         size := sizeof(double);
@@ -597,6 +597,10 @@ begin
             pchar(Buffer)[tel-1] := CurrBuff[i-tel];
 
           dbl^ := (dbl^+3.1558464E+009)/86400;  // postgres counts seconds elapsed since 1-1-2000
+          // Now convert the mathematically-correct datetime to the
+          // illogical windows/delphi/fpc TDateTime:
+          if (dbl^ <= 0) and (frac(dbl^)<0) then
+            dbl^ := trunc(dbl^)-2-frac(dbl^);
           end;
         ftBCD:
           begin