Browse Source

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

git-svn-id: trunk@40201 -
yury 6 years ago
parent
commit
e63433c88c
1 changed files with 10 additions and 10 deletions
  1. 10 10
      rtl/android/unixandroid.inc

+ 10 - 10
rtl/android/unixandroid.inc

@@ -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;
-  tt:=localtime(@t);
+  ReadTimeZoneFromLibC:=False;
   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
-    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;
     ReadTimeZoneFromICU;
 end;
 end;