1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-04-17 06:57:13 +02:00

Catch date conversion exceptions

This commit is contained in:
Salvador Díaz Fau 2018-09-18 16:19:21 +02:00
parent 833d50134a
commit 54a88d04fa

View File

@ -420,18 +420,32 @@ function CefTimeToDateTime(const dt: TCefTime): TDateTime;
var var
TempTime : TSystemTime; TempTime : TSystemTime;
begin begin
TempTime := CefTimeToSystemTime(dt); Result := 0;
SystemTimeToTzSpecificLocalTime(nil, @TempTime, @TempTime);
Result := SystemTimeToDateTime(TempTime); try
TempTime := CefTimeToSystemTime(dt);
SystemTimeToTzSpecificLocalTime(nil, @TempTime, @TempTime);
Result := SystemTimeToDateTime(TempTime);
except
on e : exception do
if CustomExceptionHandler('CefTimeToDateTime', e) then raise;
end;
end; end;
function DateTimeToCefTime(dt: TDateTime): TCefTime; function DateTimeToCefTime(dt: TDateTime): TCefTime;
var var
TempTime : TSystemTime; TempTime : TSystemTime;
begin begin
DateTimeToSystemTime(dt, TempTime); FillChar(Result, SizeOf(TCefTime), 0);
TzSpecificLocalTimeToSystemTime(nil, @TempTime, @TempTime);
Result := SystemTimeToCefTime(TempTime); try
DateTimeToSystemTime(dt, TempTime);
TzSpecificLocalTimeToSystemTime(nil, @TempTime, @TempTime);
Result := SystemTimeToCefTime(TempTime);
except
on e : exception do
if CustomExceptionHandler('DateTimeToCefTime', e) then raise;
end;
end; end;
function cef_string_wide_copy(const src: PWideChar; src_len: NativeUInt; output: PCefStringWide): Integer; function cef_string_wide_copy(const src: PWideChar; src_len: NativeUInt; output: PCefStringWide): Integer;
@ -1817,40 +1831,40 @@ begin
end; end;
function DeleteDirContents(const aDirectory : string) : boolean; function DeleteDirContents(const aDirectory : string) : boolean;
var var
TempRec : TSearchRec; TempRec : TSearchRec;
TempPath : string; TempPath : string;
begin begin
Result := True; Result := True;
try try
if (length(aDirectory) > 0) and if (length(aDirectory) > 0) and
DirectoryExists(aDirectory) and DirectoryExists(aDirectory) and
(FindFirst(aDirectory + '\*', faAnyFile, TempRec) = 0) then (FindFirst(aDirectory + '\*', faAnyFile, TempRec) = 0) then
try try
repeat repeat
TempPath := aDirectory + PathDelim + TempRec.Name; TempPath := aDirectory + PathDelim + TempRec.Name;
if ((TempRec.Attr and faDirectory) <> 0) then if ((TempRec.Attr and faDirectory) <> 0) then
begin begin
if (TempRec.Name <> '.') and (TempRec.Name <> '..') then if (TempRec.Name <> '.') and (TempRec.Name <> '..') then
begin begin
if DeleteDirContents(TempPath) then if DeleteDirContents(TempPath) then
Result := RemoveDir(TempPath) and Result Result := RemoveDir(TempPath) and Result
else else
Result := False; Result := False;
end; end;
end end
else else
Result := DeleteFile(TempPath) and Result; Result := DeleteFile(TempPath) and Result;
until (FindNext(TempRec) <> 0) or not(Result); until (FindNext(TempRec) <> 0) or not(Result);
finally finally
FindClose(TempRec); FindClose(TempRec);
end; end;
except except
on e : exception do on e : exception do
if CustomExceptionHandler('DeleteDirContents', e) then raise; if CustomExceptionHandler('DeleteDirContents', e) then raise;
end; end;
end; end;
end. end.