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

@ -116,8 +116,8 @@ function CefInt64Set(int32_low, int32_high: Integer): Int64;
function CefInt64GetLow(const int64_val: Int64): Integer; function CefInt64GetLow(const int64_val: Int64): Integer;
function CefInt64GetHigh(const int64_val: Int64): Integer; function CefInt64GetHigh(const int64_val: Int64): Integer;
function CefGetObject(ptr: Pointer): TObject; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} function CefGetObject(ptr: Pointer): TObject; {$IFDEF SUPPORTS_INLINE}inline;{$ENDIF}
function CefGetData(const i: ICefBaseRefCounted): Pointer; {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} function CefGetData(const i: ICefBaseRefCounted): Pointer; {$IFDEF SUPPORTS_INLINE}inline;{$ENDIF}
function CefStringAlloc(const str: ustring): TCefString; function CefStringAlloc(const str: ustring): TCefString;
function CefStringClearAndGet(str: PCefString): ustring; function CefStringClearAndGet(str: PCefString): ustring;
@ -128,7 +128,7 @@ function CefUserFreeString(const str: ustring): PCefStringUserFree;
procedure CefStringFree(const str: PCefString); procedure CefStringFree(const str: PCefString);
function CefStringFreeAndGet(const str: PCefStringUserFree): ustring; function CefStringFreeAndGet(const str: PCefStringUserFree): ustring;
procedure CefStringSet(const str: PCefString; const value: ustring); procedure CefStringSet(const str: PCefString; const value: ustring);
procedure CefStringInitialize(const aCefString : PCefString); {$IFDEF SUPPORTS_INLINE} inline; {$ENDIF} procedure CefStringInitialize(const aCefString : PCefString); {$IFDEF SUPPORTS_INLINE}inline;{$ENDIF}
function CefRegisterExtension(const name, code: ustring; const Handler: ICefv8Handler): Boolean; function CefRegisterExtension(const name, code: ustring; const Handler: ICefv8Handler): Boolean;
@ -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;
end; DayTable := @MonthDays[IsLeapYear(Result.year)];
{$ELSE} Result.day_of_month := min(DayTable^[Result.month], max(1, Result.day_of_month));
Result := EncodeDate(dt.year, dt.month, dt.day_of_month) + EncodeTime(dt.hour, dt.minute, dt.second, dt.millisecond); end;
{$ENDIF}
function CefTimeToDateTime(const dt: TCefTime): TDateTime;
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"
} }