GMT Time To Local Time and vice versa
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
function fetchGMTBias: Integer; var TZinfo: TTimeZoneInformation; Mode: DWord; begin Mode := GetTimeZoneInformation(TZinfo); Result := TZinfo.Bias; case Mode of TIME_ZONE_ID_INVALID: RaiseLastOSError; TIME_ZONE_ID_STANDARD: Result := Result +TZinfo.StandardBias; TIME_ZONE_ID_DAYLIGHT: Result := Result + TZinfo.DaylightBias; end; end; function LocaleToGMT(const aValue: TDateTime): TDateTime; begin Result := aValue + (fetchGMTBias / (24*60)); end; function GMTToLocale(const aValue: TDateTime): TDateTime; begin Result := aValue - (fetchGMTBias / (24*60)); end; |