Browse Source

* Allow sqlite time(intervals) > 24 hours

git-svn-id: trunk@17411 -
joost 14 years ago
parent
commit
30a019d421
1 changed files with 13 additions and 4 deletions
  1. 13 4
      packages/fcl-db/src/sqldb/sqlite/sqlite3conn.pp

+ 13 - 4
packages/fcl-db/src/sqldb/sqlite/sqlite3conn.pp

@@ -444,7 +444,7 @@ begin
         Result:=EncodeDate(Year,Month,Day);
 end;
 
-Function ParseSQLiteTime(S : ShortString) : TDateTime;
+Function ParseSQLiteTime(S : ShortString; Interval: boolean) : TDateTime;
 
 Var
   Hour, Min, Sec : Integer;
@@ -454,7 +454,12 @@ begin
   If TryStrToInt(NextWord(S,':'),Hour) then
     if TryStrToInt(NextWord(S,':'),Min) then
       if TryStrToInt(NextWord(S,':'),Sec) then
-        Result:=EncodeTime(Hour,Min,Sec,0);
+        begin
+        if Interval then
+          Result:=EncodeTimeInterval(Hour,Min,Sec,0)
+        else
+          Result:=EncodeTime(Hour,Min,Sec,0);
+        end;
 end;
 
 Function ParseSQLiteDateTime(S : String) : TDateTime;
@@ -480,7 +485,7 @@ begin
     else if (Pos(':',S)<>0) then
       TS:=S;
     end;
-  Result:=ComposeDateTime(ParseSQLiteDate(DS),ParseSQLiteTime(TS));
+  Result:=ComposeDateTime(ParseSQLiteDate(DS),ParseSQLiteTime(TS,False));
 end;
 function TSQLite3Connection.LoadField(cursor : TSQLCursor;FieldDef : TfieldDef;buffer : pointer; out CreateBlob : boolean) : boolean;
 
@@ -520,7 +525,11 @@ begin
                begin
                setlength(str1,sqlite3_column_bytes(st,fnum));
                move(sqlite3_column_text(st,fnum)^,str1[1],length(str1));
-               PDateTime(Buffer)^:=ParseSqliteDateTime(str1)
+               case FieldDef.datatype of
+                 ftDateTime: PDateTime(Buffer)^:=ParseSqliteDateTime(str1);
+                 ftDate    : PDateTime(Buffer)^:=ParseSqliteDate(str1);
+                 ftTime    : PDateTime(Buffer)^:=ParseSQLiteTime(str1,true);
+               end; {case}
                end
              else
                Pdatetime(buffer)^:= sqlite3_column_double(st,fnum);