![]() |
lokale Zeit und UTC
folgende Funktionen liefern
Delphi-Quellcode:
unit TimeUtils;
interface function NowUTC: TDateTime; function DateUTC: TDateTime; function TimeUTC: TDateTime; function GetTimeZoneBias:TDateTime; implementation uses Windows, SysUtils; // liefert die aktuelle Systemzeit in Coordinated Universal Time (UTC) function NowUTC: TDateTime; var SystemTime: TSystemTime; begin GetSystemTime(SystemTime); with SystemTime do Result := EncodeDate(wYear, wMonth, wDay) + EncodeTime(wHour, wMinute, wSecond, wMilliseconds); end; function DateUTC: TDateTime; begin Result := Int(NowUTC); end; function TimeUTC: TDateTime; begin Result := Frac(NowUTC); end; // liefert den Abstand der lokalen Zeit zu UTC // UTC = lokaleZeit + GetTimeZoneBias function GetTimeZoneBias:TDateTime; const MINUTES_PER_DAY = 24.0 * 60.0; var tzi : TTimeZoneInformation; begin case GetTimeZoneInformation(tzi) of TIME_ZONE_ID_STANDARD: result := (tzi.Bias) / MINUTES_PER_DAY; TIME_ZONE_ID_DAYLIGHT: // Sommerzeit Result := (tzi.Bias+tzi.DaylightBias) / MINUTES_PER_DAY; else Result := 0.0; end; end; end. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 14:20 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz