Autor Beitrag
phoque
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32



BeitragVerfasst: Mo 14.11.05 14:08 
Hallo,

ich habe zwar schon gesucht aber nichts gefunden.
Gibt es irgendwie eine Funktion die mir eine Zeit mit Datum (MEZ) in GMT umrechnet?
Ich habe zwar wohl schon was gefunden, aber dabei wird dann die Zeitumstellung nicht beruecksichtigt.

gruss

phoque


Moderiert von user profile iconraziel: Topic aus VisualCLX (Component Library for Cross Platform) verschoben am Mo 14.11.2005 um 13:16
chrisw
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 439
Erhaltene Danke: 3

W2K
D7
BeitragVerfasst: Mo 14.11.05 14:48 
Das geht wie folgt :

ausblenden Delphi-Quelltext
1:
2:
3:
4:
var TZ : Time_Zone_Information;

GetTimeZoneInformation(TZ);
Stunden der aktuellen Rechnerzeit - TZ.Bias div 60// = GMT


Moderiert von user profile iconAXMD: Delphi-Tags hinzugefügt.

_________________
Man sollte keine Dummheit zweimal begehen, die Auswahl ist schließlich groß genug.
phoque Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32



BeitragVerfasst: Di 15.11.05 13:03 
bei mir rechnet er da irgendwie immer nur nen Tag drauf, egal ob winter oder sommerzeit??

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
var
 lDateConverter: TXsCustomDateTime;
 aValue: TDateTime;
 var TZ : Time_Zone_Information;
 ...
begin
 showmessage(Datum);           //2003-03-04 16:35
 GetTimeZoneInformation(TZ);
 aValue := strtodatetime(Datum) - TZ.Bias div 60// = GMT
 showmessage(dateTimetostr(aValue));        //2003-03-05 16:35
 ...
end;


phoque
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 15.11.05 13:18 
Nimm mal TZ.DaylightBias

Zitat:

DaylightBias
Bias value to be used during local time translations that occur during daylight saving time. This member is ignored if a value for the DaylightDate member is not supplied.
This value is added to the value of the Bias member to form the bias used during daylight saving time. In most time zones, the value of this member is –60.
chrisw
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 439
Erhaltene Danke: 3

W2K
D7
BeitragVerfasst: Di 15.11.05 13:31 
Vielleicht hilft Dir das ?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure TForm1.Button1Click(Sender: TObject);
var tt : TDateTime;
    ST : _SystemTime;
    TZ : Time_Zone_Information;
begin
    tt := now;
    DecodeTime(tt,ST.wHour,ST.wMinute,ST.wSecond,ST.wMilliSeconds);
    GetTimeZoneInformation(TZ);
    ST.wHour := ST.wHour + TZ.Bias div 60 + TZ.DaylightBias div 60
//Bias ist der Zeitabstand bis zu GMT in Minuten //hier -60 Minuten
//DayLightBias ist der Zeitabstand von Sommerzeit zur Winterzeit in Minuten (Wobei Winterzeit 0 und Sommerzeit -60 ist)
    Showmessage(TimeToStr(EncodeTime(ST.wHour,ST.wMinute,ST.wSecond,ST.wMilliSeconds)));
 end;



EDIT: Hier muss natürlich noch der Fehler abgefandegn werden, wenn ST.wHour nach der Manipulation < 0 ist. (also z,Bsp bei Sommerzeit um 0100 Uhr Nacht wäre St.wHour ja -1)

_________________
Man sollte keine Dummheit zweimal begehen, die Auswahl ist schließlich groß genug.