mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-07 21:06:03 +02:00
* Extend GetLocalTimeOffset to return Dst or not
This commit is contained in:
parent
4427392d56
commit
545db4a070
@ -1613,7 +1613,7 @@ begin
|
||||
Result:=0;
|
||||
end;
|
||||
|
||||
function GetLocalTimeOffset(const DateTime: TDateTime; const InputIsUTC: Boolean; out Offset: Integer): Boolean;
|
||||
function GetLocalTimeOffset(const DateTime: TDateTime; const InputIsUTC: Boolean; out Offset: Integer; out isDST : Boolean): Boolean;
|
||||
begin
|
||||
Result:=False;
|
||||
end;
|
||||
@ -1624,9 +1624,21 @@ begin
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
function GetLocalTimeOffset(const DateTime: TDateTime; const InputIsUTC: Boolean): Integer;
|
||||
function GetLocalTimeOffset(const DateTime: TDateTime; const InputIsUTC: Boolean; out Offset: Integer): Boolean;
|
||||
|
||||
var
|
||||
dst : Boolean;
|
||||
|
||||
begin
|
||||
if not GetLocalTimeOffset(DateTime, InputIsUTC, Result) then
|
||||
Result:=GetLocalTimeOffset(DateTime,InputIsUTC,Offset,dst);
|
||||
end;
|
||||
|
||||
|
||||
function GetLocalTimeOffset(const DateTime: TDateTime; const InputIsUTC: Boolean): Integer;
|
||||
var
|
||||
dst : Boolean;
|
||||
begin
|
||||
if not GetLocalTimeOffset(DateTime, InputIsUTC, Result,dst) then
|
||||
Result:=GetLocalTimeOffset();
|
||||
end;
|
||||
|
||||
|
@ -209,6 +209,7 @@ procedure ReplaceDate(var DateTime: TDateTime; const NewDate: TDateTime); inline
|
||||
|
||||
function GetLocalTimeOffset: Integer;
|
||||
function GetLocalTimeOffset(const DateTime: TDateTime; const InputIsUTC: Boolean; out Offset: Integer): Boolean;
|
||||
function GetLocalTimeOffset(const DateTime: TDateTime; const InputIsUTC: Boolean; out Offset: Integer; out IsDST : Boolean): Boolean;
|
||||
function GetLocalTimeOffset(const DateTime: TDateTime; const InputIsUTC: Boolean = False): Integer;
|
||||
|
||||
{ UTC <-> Local time }
|
||||
|
@ -914,12 +914,13 @@ end;
|
||||
{$ENDIF HAS_DUAL_TZHANDLING}
|
||||
|
||||
|
||||
function GetLocalTimeOffset(const DateTime: TDateTime; const InputIsUTC: boolean; out Offset: integer): boolean;
|
||||
function GetLocalTimeOffset(const DateTime: TDateTime; const InputIsUTC: boolean; out Offset: integer; out isDST : Boolean): boolean;
|
||||
var
|
||||
SystemTime: TSystemTime;
|
||||
begin
|
||||
DateTimeToSystemTime (DateTime, SystemTime);
|
||||
if InDST (SystemTime, InputIsUTC) then
|
||||
isDST:=InDST (SystemTime, InputIsUTC);
|
||||
if isDST then
|
||||
Offset := DSTOffsetMin
|
||||
else
|
||||
Offset := TZOffsetMin;
|
||||
|
@ -1886,7 +1886,8 @@ begin
|
||||
Result := -Tzseconds div 60;
|
||||
end;
|
||||
|
||||
function GetLocalTimeOffset(const DateTime: TDateTime; const InputIsUTC: Boolean; out Offset: Integer): Boolean;
|
||||
|
||||
function GetLocalTimeOffset(const DateTime: TDateTime; const InputIsUTC: Boolean; out Offset: Integer; out IsDST : Boolean): Boolean;
|
||||
|
||||
var
|
||||
Year, Month, Day, Hour, Minute, Second, MilliSecond: word;
|
||||
@ -1896,9 +1897,9 @@ begin
|
||||
DecodeDate(DateTime, Year, Month, Day);
|
||||
DecodeTime(DateTime, Hour, Minute, Second, MilliSecond);
|
||||
UnixTime:=UniversalToEpoch(Year, Month, Day, Hour, Minute, Second);
|
||||
|
||||
{$if declared(GetLocalTimezone)}
|
||||
GetLocalTimeOffset:=GetLocalTimezone(UnixTime,InputIsUTC,lTZInfo);
|
||||
isDST:=lTZInfo.daylight;
|
||||
if GetLocalTimeOffset then
|
||||
Offset:=-lTZInfo.seconds div 60;
|
||||
{$else}
|
||||
|
@ -992,7 +992,7 @@ type
|
||||
var
|
||||
GetTimeZoneInformationForYear:TGetTimeZoneInformationForYear=nil;
|
||||
|
||||
function GetLocalTimeOffset(const DateTime: TDateTime; const InputIsUTC: Boolean; out Offset: Integer): Boolean;
|
||||
function GetLocalTimeOffset(const DateTime: TDateTime; const InputIsUTC: Boolean; out Offset: Integer; Out IsDST : boolean): Boolean;
|
||||
var
|
||||
Year: Integer;
|
||||
const
|
||||
@ -1053,12 +1053,16 @@ begin
|
||||
DSTStart := DSTStart + (TZInfo.Bias+TZInfo.StandardBias)/MinsPerDay;
|
||||
DSTEnd := DSTEnd + (TZInfo.Bias+TZInfo.DaylightBias)/MinsPerDay;
|
||||
end;
|
||||
if (DSTStart<=DateTime) and (DateTime<DSTEnd) then
|
||||
IsDST:=(DSTStart<=DateTime) and (DateTime<DSTEnd);
|
||||
if isDst then
|
||||
Offset := TZInfo.Bias+TZInfo.DaylightBias
|
||||
else
|
||||
Offset := TZInfo.Bias+TZInfo.StandardBias;
|
||||
end else // no DST
|
||||
begin
|
||||
Offset := TZInfo.Bias;
|
||||
IsDST := False;
|
||||
end;
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user