I test function UTCToLocal with RAD Studio 10.4 As you can see it is wrong for some configurations: if all defines will not be fuction UTCToLocal doesn't contains begin end; at all.
function UTCToLocal(Input: TDateTime): TDateTime;
{$IFDEF WDC}
begin
Result := TTimeZone.Local.ToLocalTime(Input);
end;
{$ENDIF}
//There seems to be no easy way to do this in FPC without an external library
//From: http://lists.lazarus.freepascal.org/pipermail/lazarus/2010-September/055568.html
{$IFDEF FPC}
var
TZOffset: Integer;
{$IFDEF MSWINDOWS}
BiasType: Byte;
TZInfo: TTimeZoneInformation;
{$ENDIF}
begin
Result := Input;
{$IFDEF MSWINDOWS}
BiasType := GetTimeZoneInformation(TZInfo);
if (BiasType=0) then
Exit; //No timezone so return the input
// Determine offset in effect for DateTime UT.
if (BiasType=2) then
TZOffset := TZInfo.Bias + TZInfo.DaylightBias
else
TZOffset := TZInfo.Bias + TZInfo.StandardBias;
{$ENDIF}
{$IFDEF UNIX}
TZOffset := -Tzseconds div 60;
{$ENDIF}
// Apply offset.
if (TZOffset > 0) then
// Time zones west of Greenwich.
Result := Input - EncodeTime(TZOffset div 60, TZOffset mod 60, 0, 0)
else if (TZOffset = 0) then
// Time Zone = Greenwich.
Result := Input
else if (TZOffset < 0) then
// Time zones east of Greenwich.
Result := Input + EncodeTime(Abs(TZOffset) div 60, Abs(TZOffset) mod 60, 0, 0);
end;
{$ENDIF}
I test function UTCToLocal with RAD Studio 10.4 As you can see it is wrong for some configurations: if all defines will not be fuction UTCToLocal doesn't contains begin end; at all.