Reputation: 41
I use Rad Studio 12.2 Patch 2.
I get serverdate value from server and tried to convert it to DateTime by using StrInternetToDateTime. My serverdate is like Fri, 21 Feb 2025 22:11:34 GMT
On windows platform there is no problem. It works correct. But on Android 32 phone gives exception on EncodeDate. Project Myproject.apk raised exception class EConvertError with message 'Invalid argument to date encode'.
When i debug it saw that on ParseMonth and ParseDayOfMonth procedures the month and day values are wrong.
I call this to reproduce the error. The param is the date that i got from my server.
StrInternetToDateTime ('Fri, 21 Feb 2025 22:11:34 GMT') ;
I am calling this on old Samsung phone. The Android version is 32-Bit Android 8.1.0
and i get this error :
Project PlayGround.apk raised exception class EConvertError with message 'Invalid argument to date encode'.
on System.SysUtils Unit
function EncodeDate(Year, Month, Day: Word): TDateTime;
begin
if not TryEncodeDate(Year, Month, Day, Result) then
ConvertError(@SDateEncodeError);
end;
On ParseMonth Procedure
Mo := StrToMonth( Fetch (Value, sDelim) );
here MO value extracted as 0
On RawStrInternetToDateTime Main Body
sYear := Fetch(Value);
here sYear is 'Feb'
But when i change target platform to Windows 32-bit it returns 21.02.2025
Upvotes: 0
Views: 51