diff --git a/rtl/unix/sysutils.pp b/rtl/unix/sysutils.pp index 90b4ae28f8..d59ded2edc 100644 --- a/rtl/unix/sysutils.pp +++ b/rtl/unix/sysutils.pp @@ -1648,22 +1648,15 @@ var begin DecodeDate(DateTime, Year, Month, Day); DecodeTime(DateTime, Hour, Minute, Second, MilliSecond); - if InputIsUTC then - UnixTime:=UniversalToEpoch(Year, Month, Day, Hour, Minute, Second) - else - UnixTime:=LocalToEpoch(Year, Month, Day, Hour, Minute, Second); - { check if time is in current global Tzinfo } - lTzinfo:=Tzinfo; - if (lTzinfo.validsince<=UnixTime) and (UnixTime=transitions[i] then + Exit(1) + else + Exit(0); + end; begin if (num_transitions=0) or (timer0) then + L := I+1 + else begin + R := I-1; + if (CompareRes=0) then + L:=I; // break cycle + end; + end; + trans_start:=transitions[i-1]; trans_end:=transitions[i]; i:=type_idxs[i-1]; @@ -128,7 +152,17 @@ function GetLocalTimezone(timer:cint;timerIsUTC:Boolean;var ATZInfo:TTZInfo):Boo var info: pttinfo; trans_start,trans_end: longint; + timerUTC: cint; begin + { check if time is in current global Tzinfo } + ATZInfo:=CurrentTZinfo[InterlockedExchangeAdd(CurrentTZindex, 0)]; + if not timerIsUTC then + timerUTC:=timer-ATZInfo.seconds + else + timerUTC:=timer; + if (ATZInfo.validsince<=timerUTC) and (timerUTC'/' then fn:=TimeZoneDir+fn; f:=fpopen(fn,Open_RdOnly); if f<0 then - exit; + begin + UnlockTZInfo; + exit(False); + end; bufptr := @buf[bufsize-1]+1; i:=readbuf(tzhead,sizeof(tzhead)); if i<>sizeof(tzhead) then - exit; + begin + UnlockTZInfo; + exit(False); + end; decode(tzhead.tzh_timecnt); decode(tzhead.tzh_typecnt); decode(tzhead.tzh_charcnt); @@ -308,6 +363,8 @@ begin types[i].isgmt:=byte(readbufbyte<>0); fpclose(f); + ReadTimezoneFile:=True; + UnlockTZInfo; end; Const diff --git a/rtl/unix/unix.pp b/rtl/unix/unix.pp index 18c416e54d..c003cc2e72 100644 --- a/rtl/unix/unix.pp +++ b/rtl/unix/unix.pp @@ -91,7 +91,7 @@ type function GetLocalTimezone(timer:cint;timerIsUTC:Boolean;var ATZInfo:TTZInfo;var ATZInfoEx:TTZInfoEx):Boolean; function GetLocalTimezone(timer:cint;timerIsUTC:Boolean;var ATZInfo:TTZInfo):Boolean; procedure RefreshTZInfo; -procedure ReadTimezoneFile(fn:string); +function ReadTimezoneFile(fn:string) : Boolean; function GetTimezoneFile:string; Procedure ReReadLocalTime; {$ENDIF} @@ -299,22 +299,13 @@ Procedure EpochToLocal(epoch:Int64;var year,month,day,hour,minute,second:Word); } Var lTZInfo: TTZInfo; - lseconds: LongInt; Begin - { check if time is in current global Tzinfo } - lTZInfo:=TZInfo; - lseconds:=lTZInfo.seconds; - if (lTZInfo.validsince<=epoch) and (epoch