in the lines below the error: "Invalid argument", must be because of the time zone. How do I solve the problem?
{ Now adjust TDateTime based on any offsets we have and the local bias }
{ There are two possibilities:
a. The time we have has the same offset as the local bias - nothing to do!!
b. The time we have and the local bias are different - requiring adjustments }
tz := TTimeZone.Local;
BiasLocal := Trunc(tz.GetUTCOffset(Result).Negate.TotalMinutes);
BiasTime := (AHourOffset * MinsPerHour) + AMinuteOffset;
if (BiasLocal + BiasTime) = 0 then
Exit;
{ Here we adjust the Local Bias to make it relative to the Time's own offset
instead of being relative to GMT }
BiasLocal := BiasLocal + BiasTime;
BiasHour := Abs(BiasLocal) div MinsPerHour;
BiasMins := Abs(BiasLocal) mod MinsPerHour;
BiasDT := EncodeTime(BiasHour, BiasMins, 0, 0);
if (BiasLocal > 0) then
Result := Result - BiasDT
else
Result := Result + BiasDT;