mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-18 20:09:18 +02:00
* timezones android compilation
git-svn-id: trunk@47326 -
(cherry picked from commit 7ded8307c9
)
This commit is contained in:
parent
cb4d59156e
commit
569c36cfa4
@ -53,7 +53,7 @@ var
|
|||||||
err: UErrorCode;
|
err: UErrorCode;
|
||||||
cal: UCalendar;
|
cal: UCalendar;
|
||||||
lTZInfo: TTZInfo;
|
lTZInfo: TTZInfo;
|
||||||
lTZInfoEx: TTZInfo;
|
lTZInfoEx: TTZInfoEx;
|
||||||
begin
|
begin
|
||||||
if not Assigned(GetIcuProc) then exit;
|
if not Assigned(GetIcuProc) then exit;
|
||||||
if not GetIcuProc('ucal_open', ucal_open, 1) then exit;
|
if not GetIcuProc('ucal_open', ucal_open, 1) then exit;
|
||||||
@ -122,17 +122,25 @@ function ReadTimeZoneFromLibC: boolean;
|
|||||||
var
|
var
|
||||||
t: time_t;
|
t: time_t;
|
||||||
tt: Ptm;
|
tt: Ptm;
|
||||||
|
lTZInfo: TTZInfo;
|
||||||
|
lTZInfoEx: TTZInfoEx;
|
||||||
begin
|
begin
|
||||||
ReadTimeZoneFromLibC:=False;
|
ReadTimeZoneFromLibC:=False;
|
||||||
tzname[false]:=c_tzname[0];
|
lTZInfo:=default(TTZInfo);
|
||||||
tzname[true]:=c_tzname[1];
|
lTZInfoEx:=default(TTZInfoEx);
|
||||||
|
lTZInfoEx.name[false]:=c_tzname[0];
|
||||||
|
lTZInfoEx.name[true]:=c_tzname[1];
|
||||||
t:=fptime;
|
t:=fptime;
|
||||||
tt:=localtime(@t);
|
tt:=localtime(@t);
|
||||||
if tt <> nil then
|
if tt <> nil then
|
||||||
begin
|
begin
|
||||||
tzdaylight:=tt^.tm_isdst <> 0;
|
lTZInfo.daylight:=tt^.tm_isdst <> 0;
|
||||||
tzseconds:=tt^.tm_gmtoff;
|
lTZInfo.seconds:=tt^.tm_gmtoff;
|
||||||
ReadTimeZoneFromLibC:=tzname[false] <> nil;
|
// ToDo: correct validsince/validuntil values
|
||||||
|
lTZInfo.validsince:=low(lTZInfo.validsince);
|
||||||
|
lTZInfo.validuntil:=high(lTZInfo.validuntil);
|
||||||
|
SetTZInfo(lTZInfo, lTZInfoEx);
|
||||||
|
ReadTimeZoneFromLibC:=lTZInfoEx.name[false] <> '';
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -232,16 +232,20 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function GetTZInfo : TTZInfo;
|
function GetTZInfo : TTZInfo;
|
||||||
|
{$IFNDEF DONT_READ_TIMEZONE}
|
||||||
var
|
var
|
||||||
curtime: time_t;
|
curtime: time_t;
|
||||||
|
{$ENDIF}
|
||||||
begin
|
begin
|
||||||
GetTZInfo:=CurrentTZinfo[InterlockedExchangeAdd(CurrentTZindex, 0)];
|
GetTZInfo:=CurrentTZinfo[InterlockedExchangeAdd(CurrentTZindex, 0)];
|
||||||
|
{$IFNDEF DONT_READ_TIMEZONE}
|
||||||
curtime:=fptime;
|
curtime:=fptime;
|
||||||
if not((GetTZInfo.validsince+GetTZInfo.seconds<=curtime) and (curtime<GetTZInfo.validuntil+GetTZInfo.seconds)) then
|
if not((GetTZInfo.validsince+GetTZInfo.seconds<=curtime) and (curtime<GetTZInfo.validuntil+GetTZInfo.seconds)) then
|
||||||
begin
|
begin
|
||||||
RefreshTZInfo;
|
RefreshTZInfo;
|
||||||
GetTZInfo:=CurrentTZinfo[InterlockedExchangeAdd(CurrentTZindex, 0)];
|
GetTZInfo:=CurrentTZinfo[InterlockedExchangeAdd(CurrentTZindex, 0)];
|
||||||
end;
|
end;
|
||||||
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function GetTZInfoEx : TTZInfoEx;
|
function GetTZInfoEx : TTZInfoEx;
|
||||||
|
Loading…
Reference in New Issue
Block a user