* revert r47532, r47527 (use timezone information from fpgettimeofday) because they are not available on all Linux distributions

git-svn-id: trunk@47541 -
This commit is contained in:
ondrej 2020-11-23 15:17:52 +00:00
parent 0323f0b07d
commit 63beb1e83a
2 changed files with 18 additions and 27 deletions

View File

@ -144,13 +144,11 @@ end;
Procedure GetDate(Var Year, Month, MDay, WDay: Word); Procedure GetDate(Var Year, Month, MDay, WDay: Word);
var var
tv:timeval; tz:timeval;
tz:timezone;
hour,min,sec : word; hour,min,sec : word;
begin begin
fpgettimeofday(@tv,@tz); fpgettimeofday(@tz,nil);
tv.tv_sec:=tv.tv_sec-tz.tz_minuteswest*60; EpochToLocal(tz.tv_sec,year,month,mday,hour,min,sec);
EpochToUniversal(tv.tv_sec,year,month,mday,hour,min,sec);
Wday:=weekday(Year,Month,MDay); Wday:=weekday(Year,Month,MDay);
end; end;
@ -191,14 +189,12 @@ end;
Procedure GetTime(Var Hour, Minute, Second, Sec100: Word); Procedure GetTime(Var Hour, Minute, Second, Sec100: Word);
var var
tv:timeval; tz:timeval;
tz:timezone;
year,month,day : word; year,month,day : word;
begin begin
fpgettimeofday(@tv,@tz); fpgettimeofday(@tz,nil);
tv.tv_sec:=tv.tv_sec-tz.tz_minuteswest*60; EpochToLocal(tz.tv_sec,year,month,day,hour,minute,second);
EpochToUniversal(tv.tv_sec,year,month,day,hour,minute,second); sec100:=tz.tv_usec div 10000;
sec100:=tv.tv_usec div 10000;
end; end;

View File

@ -1191,12 +1191,12 @@ end;
Procedure DoGetUniversalDateTime(var year, month, day, hour, min, sec, msec, usec : word); Procedure DoGetUniversalDateTime(var year, month, day, hour, min, sec, msec, usec : word);
var var
tp:timeval; tz:timeval;
begin begin
fpgettimeofday(@tp,nil); fpgettimeofday(@tz,nil);
EpochToUniversal(tp.tv_sec,year,month,day,hour,min,sec); EpochToUniversal(tz.tv_sec,year,month,day,hour,min,sec);
msec:=tp.tv_usec div 1000; msec:=tz.tv_usec div 1000;
usec:=tp.tv_usec mod 1000; usec:=tz.tv_usec mod 1000;
end; end;
// Now, adjusted to local time. // Now, adjusted to local time.
@ -1204,14 +1204,12 @@ end;
Procedure DoGetLocalDateTime(var year, month, day, hour, min, sec, msec, usec : word); Procedure DoGetLocalDateTime(var year, month, day, hour, min, sec, msec, usec : word);
var var
tv:timeval; tz:timeval;
tz:timezone;
begin begin
fpgettimeofday(@tv,@tz); fpgettimeofday(@tz,nil);
tv.tv_sec:=tv.tv_sec-tz.tz_minuteswest*60; EpochToLocal(tz.tv_sec,year,month,day,hour,min,sec);
EpochToUniversal(tv.tv_sec,year,month,day,hour,min,sec); msec:=tz.tv_usec div 1000;
msec:=tv.tv_usec div 1000; usec:=tz.tv_usec mod 1000;
usec:=tv.tv_usec mod 1000;
end; end;
procedure GetTime(var hour,min,sec,msec,usec:word); procedure GetTime(var hour,min,sec,msec,usec:word);
@ -1649,11 +1647,8 @@ end;
function GetLocalTimeOffset: Integer; function GetLocalTimeOffset: Integer;
var
tz:timezone;
begin begin
fpgettimeofday(nil,@tz); Result := -Tzseconds div 60;
GetLocalTimeOffset:=tz.tz_minuteswest;
end; end;
function GetLocalTimeOffset(const DateTime: TDateTime; const InputIsUTC: Boolean; out Offset: Integer): Boolean; function GetLocalTimeOffset(const DateTime: TDateTime; const InputIsUTC: Boolean; out Offset: Integer): Boolean;