* Fixed obtaining a time zone information for 64-bit android.

git-svn-id: trunk@40201 -
This commit is contained in:
yury 2018-11-03 14:33:41 +00:00
parent 8958d94091
commit e63433c88c

View File

@ -104,33 +104,33 @@ type
true : (__tm_gmtoff : longint;__tm_zone : Pchar); true : (__tm_gmtoff : longint;__tm_zone : Pchar);
end; end;
function localtime(t: PLongInt): Ptm; cdecl; external 'c' name 'localtime'; function localtime(t: Ptime_t): Ptm; cdecl; external 'c' name 'localtime';
var var
c_tzname: array[0..1] of PAnsiChar; external 'c' name 'tzname'; c_tzname: array[0..1] of PAnsiChar; external 'c' name 'tzname';
procedure ReadTimeZoneFromLibC; function ReadTimeZoneFromLibC: boolean;
var var
t: longint; t: time_t;
tt: Ptm; tt: Ptm;
begin begin
t:=fptime; ReadTimeZoneFromLibC:=False;
tt:=localtime(@t);
tzname[false]:=c_tzname[0]; tzname[false]:=c_tzname[0];
tzname[true]:=c_tzname[1]; tzname[true]:=c_tzname[1];
t:=fptime;
tt:=localtime(@t);
if tt <> nil then if tt <> nil then
begin begin
tzdaylight:=tt^.tm_isdst <> 0; tzdaylight:=tt^.tm_isdst <> 0;
tzseconds:=tt^.tm_gmtoff; tzseconds:=tt^.tm_gmtoff;
ReadTimeZoneFromLibC:=tzname[false] <> nil;
end; end;
end; end;
procedure InitLocalTime; procedure InitLocalTime;
begin begin
if SystemApiLevel > 10 then if (SystemApiLevel <= 10) or not ReadTimeZoneFromLibC then
ReadTimeZoneFromLibC; // If current Android version is too old and does not support timezone
// If current Android version is too old and does not support timezone // in libc, use ICU library.
// in libc, use ICU library.
if tzname[false] = nil then
ReadTimeZoneFromICU; ReadTimeZoneFromICU;
end; end;