Changeset 17 for trunk/Packages
- Timestamp:
- Nov 15, 2012, 2:56:05 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/CoolWeb/Persistence/USqlDatabase.pas
r16 r17 91 91 function SQLToDateTime(Value: string): TDateTime; 92 92 function SQLToTime(Value: string): TDateTime; 93 function SQLToDate(Value: string): TDateTime; 93 94 function DateTimeToSQL(Value: TDateTime): string; 94 95 function TimeToSQL(Value: TDateTime): string; … … 173 174 end; 174 175 176 function SQLToDate(Value: string): TDateTime; 177 var 178 DateParts: TListString; 179 Date: TDateTime; 180 begin 181 try 182 DateParts := TListString.Create; 183 DateParts.Explode(Value, '-', StrToStr); 184 if TryEncodeDate(StrToInt(DateParts[0]), StrToInt(DateParts[1]), 185 StrToInt(DateParts[2]), Date) then 186 Result := Date else Result := 0; 187 finally 188 DateParts.Free; 189 end; 190 end; 191 175 192 function DateTimeToSQL(Value: TDateTime): string; 176 193 begin 177 Result := FormatDateTime('yyyy-mm-dd hh .nn.ss', Value);194 Result := FormatDateTime('yyyy-mm-dd hh:nn:ss', Value); 178 195 end; 179 196 180 197 function TimeToSQL(Value: TDateTime): string; 181 198 begin 182 Result := FormatDateTime('hh .nn.ss', Value);199 Result := FormatDateTime('hh:nn:ss', Value); 183 200 end; 184 201 … … 191 208 var 192 209 TimeParts: TListString; 210 Time: TDateTime; 193 211 begin 194 212 try 195 213 TimeParts := TListString.Create; 196 214 TimeParts.Explode(Value, ':', StrToStr); 197 Result := Result + EncodeTime(StrToInt(TimeParts[0]), StrToInt(TimeParts[1]), 198 StrToInt(TimeParts[2]), 0); 215 if TryEncodeTime(StrToInt(TimeParts[0]), StrToInt(TimeParts[1]), 216 StrToInt(TimeParts[2]), 0, time) then 217 Result := Time else Result := 0; 199 218 finally 200 219 TimeParts.Free;
Note:
See TracChangeset
for help on using the changeset viewer.