1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-08-14 21:42:50 +02:00

Fixed cookie date conversion issue

This commit is contained in:
Salvador Diaz Fau
2021-01-18 11:12:01 +01:00
parent 908017b2f5
commit 6ede7fa51a
2 changed files with 26 additions and 40 deletions

View File

@@ -148,6 +148,7 @@ function SystemTimeToCefTime(const dt: TSystemTime): TCefTime;
{$ENDIF} {$ENDIF}
{$ENDIF} {$ENDIF}
function FixCefTime(const dt : TCefTime): TCefTime;
function CefTimeToDateTime(const dt: TCefTime): TDateTime; function CefTimeToDateTime(const dt: TCefTime): TDateTime;
function DateTimeToCefTime(dt: TDateTime): TCefTime; function DateTimeToCefTime(dt: TDateTime): TCefTime;
@@ -176,8 +177,6 @@ procedure WindowInfoAsWindowless(var aWindowInfo : TCefWindowInfo; aParent : TCe
{$IFDEF MSWINDOWS} {$IFDEF MSWINDOWS}
function ProcessUnderWow64(hProcess: THandle; var Wow64Process: BOOL): BOOL; stdcall; external Kernel32DLL name 'IsWow64Process'; function ProcessUnderWow64(hProcess: THandle; var Wow64Process: BOOL): BOOL; stdcall; external Kernel32DLL name 'IsWow64Process';
function TzSpecificLocalTimeToSystemTime(lpTimeZoneInformation: PTimeZoneInformation; lpLocalTime, lpUniversalTime: PSystemTime): BOOL; stdcall; external Kernel32DLL;
function SystemTimeToTzSpecificLocalTime(lpTimeZoneInformation: PTimeZoneInformation; lpUniversalTime, lpLocalTime: PSystemTime): BOOL; stdcall; external Kernel32DLL;
function PathIsRelativeAnsi(pszPath: LPCSTR): BOOL; stdcall; external SHLWAPIDLL name 'PathIsRelativeA'; function PathIsRelativeAnsi(pszPath: LPCSTR): BOOL; stdcall; external SHLWAPIDLL name 'PathIsRelativeA';
function PathIsRelativeUnicode(pszPath: LPCWSTR): BOOL; stdcall; external SHLWAPIDLL name 'PathIsRelativeW'; function PathIsRelativeUnicode(pszPath: LPCWSTR): BOOL; stdcall; external SHLWAPIDLL name 'PathIsRelativeW';
function GetGlobalMemoryStatusEx(var Buffer: TMyMemoryStatusEx): BOOL; stdcall; external Kernel32DLL name 'GlobalMemoryStatusEx'; function GetGlobalMemoryStatusEx(var Buffer: TMyMemoryStatusEx): BOOL; stdcall; external Kernel32DLL name 'GlobalMemoryStatusEx';
@@ -574,48 +573,36 @@ end;
{$ENDIF} {$ENDIF}
{$ENDIF} {$ENDIF}
function CefTimeToDateTime(const dt: TCefTime): TDateTime; function FixCefTime(const dt : TCefTime): TCefTime;
{$IFDEF MSWINDOWS}
var var
TempTime : TSystemTime; DayTable : PDayTable;
{$ENDIF}
begin begin
{$IFDEF MSWINDOWS} Result := dt;
Result := 0;
try Result.year := min(9999, max(1, Result.year));
TempTime := CefTimeToSystemTime(dt); Result.month := min(12, max(1, Result.month));
SystemTimeToTzSpecificLocalTime(nil, @TempTime, @TempTime); Result.hour := min(23, max(1, Result.hour));
Result := SystemTimeToDateTime(TempTime); Result.minute := min(59, max(1, Result.minute));
except Result.second := min(59, max(1, Result.second));
on e : exception do Result.millisecond := min(999, max(1, Result.millisecond));
if CustomExceptionHandler('CefTimeToDateTime', e) then raise;
DayTable := @MonthDays[IsLeapYear(Result.year)];
Result.day_of_month := min(DayTable^[Result.month], max(1, Result.day_of_month));
end; end;
{$ELSE}
Result := EncodeDate(dt.year, dt.month, dt.day_of_month) + EncodeTime(dt.hour, dt.minute, dt.second, dt.millisecond); function CefTimeToDateTime(const dt: TCefTime): TDateTime;
{$ENDIF} var
TempFixedCefTime : TCefTime;
begin
TempFixedCefTime := FixCefTime(dt);
Result := EncodeDate(TempFixedCefTime.year, TempFixedCefTime.month, TempFixedCefTime.day_of_month) +
EncodeTime(TempFixedCefTime.hour, TempFixedCefTime.minute, TempFixedCefTime.second, TempFixedCefTime.millisecond);
end; end;
function DateTimeToCefTime(dt: TDateTime): TCefTime; function DateTimeToCefTime(dt: TDateTime): TCefTime;
var var
{$IFDEF MSWINDOWS}
TempTime : TSystemTime;
{$ELSE}
TempYear, TempMonth, TempDay, TempHour, TempMin, TempSec, TempMSec : Word; TempYear, TempMonth, TempDay, TempHour, TempMin, TempSec, TempMSec : Word;
{$ENDIF}
begin begin
{$IFDEF MSWINDOWS}
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;
{$ELSE}
DecodeDate(dt, TempYear, TempMonth, TempDay); DecodeDate(dt, TempYear, TempMonth, TempDay);
DecodeTime(dt, TempHour, TempMin, TempSec, TempMSec); DecodeTime(dt, TempHour, TempMin, TempSec, TempMSec);
@@ -627,7 +614,6 @@ begin
Result.minute := TempMin; Result.minute := TempMin;
Result.second := TempSec; Result.second := TempSec;
Result.millisecond := TempMSec; Result.millisecond := TempMSec;
{$ENDIF}
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;

View File

@@ -2,7 +2,7 @@
"UpdateLazPackages" : [ "UpdateLazPackages" : [
{ {
"ForceNotify" : true, "ForceNotify" : true,
"InternalVersion" : 232, "InternalVersion" : 233,
"Name" : "cef4delphi_lazarus.lpk", "Name" : "cef4delphi_lazarus.lpk",
"Version" : "87.1.13.0" "Version" : "87.1.13.0"
} }