获取当前用户的时区与GMT的差

  • 主题发起人 主题发起人 import
  • 开始时间 开始时间
I

import

Unregistered / Unconfirmed
GUEST, unregistred user!
function GetTimeZoneDelta: TDateTime; var
TzInfo: TTimeZoneInformation;
begin
case GetTimeZoneInformation(TzInfo) of
TIME_ZONE_ID_UNKNOWN: Result := TzInfo.Bias / 1440;
TIME_ZONE_ID_STANDARD: Result := (TzInfo.Bias + TzInfo.StandardBias) /
1440;
TIME_ZONE_ID_DAYLIGHT: Result := (TzInfo.Bias + TzInfo.DayLightBias) /
1440;
else
RaiseLastWin32Error;
end;
end;
function CurGmtToLocalMinutesOffset: integer;
var t1,g2,t3: tDateTime;
begin
t3 := Now;
Repeat
t1 := t3;
g2 := CurGmt;
t3 := Now;
Until abs(t1-t3) < 1/24/60/4;
Result := round((t3-g2)*24*60);
end;
function CurGMT: TDateTime;
var TimeRec: TSystemTime;
begin
GetSystemTime(TimeRec);
Result := SystemTimeToDateTime(TimeRec);
end;
 
后退
顶部