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