mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-08 10:48:12 +02:00
* Fixed obtaining a time zone information for 64-bit android.
git-svn-id: trunk@40201 -
This commit is contained in:
parent
8958d94091
commit
e63433c88c
@ -104,33 +104,33 @@ type
|
||||
true : (__tm_gmtoff : longint;__tm_zone : Pchar);
|
||||
end;
|
||||
|
||||
function localtime(t: PLongInt): Ptm; cdecl; external 'c' name 'localtime';
|
||||
function localtime(t: Ptime_t): Ptm; cdecl; external 'c' name 'localtime';
|
||||
|
||||
var
|
||||
c_tzname: array[0..1] of PAnsiChar; external 'c' name 'tzname';
|
||||
|
||||
procedure ReadTimeZoneFromLibC;
|
||||
function ReadTimeZoneFromLibC: boolean;
|
||||
var
|
||||
t: longint;
|
||||
t: time_t;
|
||||
tt: Ptm;
|
||||
begin
|
||||
t:=fptime;
|
||||
tt:=localtime(@t);
|
||||
ReadTimeZoneFromLibC:=False;
|
||||
tzname[false]:=c_tzname[0];
|
||||
tzname[true]:=c_tzname[1];
|
||||
t:=fptime;
|
||||
tt:=localtime(@t);
|
||||
if tt <> nil then
|
||||
begin
|
||||
tzdaylight:=tt^.tm_isdst <> 0;
|
||||
tzseconds:=tt^.tm_gmtoff;
|
||||
ReadTimeZoneFromLibC:=tzname[false] <> nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure InitLocalTime;
|
||||
begin
|
||||
if SystemApiLevel > 10 then
|
||||
ReadTimeZoneFromLibC;
|
||||
// If current Android version is too old and does not support timezone
|
||||
// in libc, use ICU library.
|
||||
if tzname[false] = nil then
|
||||
if (SystemApiLevel <= 10) or not ReadTimeZoneFromLibC then
|
||||
// If current Android version is too old and does not support timezone
|
||||
// in libc, use ICU library.
|
||||
ReadTimeZoneFromICU;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user