Autor |
Beitrag |
matze
Beiträge: 4613
Erhaltene Danke: 24
XP home, prof
Delphi 2009 Prof,
|
Verfasst: So 13.10.02 13:13
Hallo !!!
Ich progge grad ein Programm, das sich die aktuelle Zeit ausm Inet per INDY Kompo holt.
Wenn ich die systemzeit aber mit ntp1.fau.de abgleichen lasse, wird die zeit immer um +eine stunde angezeit !!!
wieso ??
vielleich weil mein system die zeitzone GMT+1 hat ??? oder wie ??
und wie lässt sich das umgehen ?
_________________ In the beginning was the word.
And the word was content-type: text/plain.
|
|
LCS
Beiträge: 1305
Erhaltene Danke: 1
WIN 7, WIN 8
Delphi XE5, Delphi XE, Delphi 2007
|
Verfasst: Mo 14.10.02 14:17
Hi
die Zeit die du via NTP bekommst, basiert immer auf GMT. Umgehen kannst du das auch nicht. Du kannst nur diese Zeit mit den Informationen der einstellten Zeitzone abgleichen.
Die Info über die eingestellte Zeitzone liefert GetTimeZoneInformation. Fertigen Code kann ich dir auf die schnelle allerdings leider net anbieten.
Gruss Lothar
_________________ Der BH ist für die Brust, der Plan ist für'n Ar...
|
|
matze
Beiträge: 4613
Erhaltene Danke: 24
XP home, prof
Delphi 2009 Prof,
|
Verfasst: Mo 14.10.02 16:30
jo. ich werd mal rumbasteln. wäre aber trotzdem nett, wenn du mal schaun könntest, ob du nen codeschnipsel posten könntest !!!
_________________ In the beginning was the word.
And the word was content-type: text/plain.
|
|
LCS
Beiträge: 1305
Erhaltene Danke: 1
WIN 7, WIN 8
Delphi XE5, Delphi XE, Delphi 2007
|
Verfasst: Mo 14.10.02 17:24
Jau, kriegst du morgen im Laufe des Tages.
Gruss Lothar
_________________ Der BH ist für die Brust, der Plan ist für'n Ar...
|
|
matze
Beiträge: 4613
Erhaltene Danke: 24
XP home, prof
Delphi 2009 Prof,
|
Verfasst: Mo 14.10.02 17:50
du bist einfach der beste *freu* !!!
dafür wiest du auch in meinem proggi genannt !!
_________________ In the beginning was the word.
And the word was content-type: text/plain.
|
|
LCS
Beiträge: 1305
Erhaltene Danke: 1
WIN 7, WIN 8
Delphi XE5, Delphi XE, Delphi 2007
|
Verfasst: Di 15.10.02 09:44
Hi
matze hat folgendes geschrieben: |
du bist einfach der beste *freu* !!!
|
Na das geht aber runter wie Öl
Und hier ist die Funktion zur Umwandlung UTC in Lokalzeit
Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13:
| function TForm1.UTC2Local(Zeit: TDateTime): TDateTime; var ti : Time_Zone_Information; i : cardinal; begin FillChar(ti, sizeof(Time_Zone_Information), 0); i := GetTimeZoneInformation( ti ); case i of TIME_ZONE_ID_UNKNOWN: Result := Zeit; TIME_ZONE_ID_STANDARD: Result := IncMinute(Zeit, ti.Bias * -1); TIME_ZONE_ID_DAYLIGHT: Result := IncMinute(Zeit, (ti.Bias + ti.DaylightBias) * -1); end; end; |
Umwandlung Lokalzeit in UTC
Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13:
| function TForm1.Local2UTC(Zeit: TDateTime): TDateTime; var ti : Time_Zone_Information; i : cardinal; begin FillChar(ti, sizeof(Time_Zone_Information), 0); i := GetTimeZoneInformation( ti ); case i of TIME_ZONE_ID_UNKNOWN: Result := Zeit; TIME_ZONE_ID_STANDARD: Result := IncMinute(Zeit, ti.Bias); TIME_ZONE_ID_DAYLIGHT: Result := IncMinute(Zeit, (ti.Bias + ti.DaylightBias) ); end; end; |
Gruss Lothar
_________________ Der BH ist für die Brust, der Plan ist für'n Ar...
|
|
matze
Beiträge: 4613
Erhaltene Danke: 24
XP home, prof
Delphi 2009 Prof,
|
Verfasst: Di 15.10.02 18:22
danke, aber mien proggi mach immernochnicht was ich will !!!! kannst du dir bitte mal den code hier anschauen !!!
Quelltext 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: 27: 28: 29:
| procedure TForm1.BitBtn1Click(Sender: TObject); var zeit : tdatetime; begin if Combobox1.Text <> '' then begin try IdTime1.Host := combobox1.Text;
zeit := idtime1.DateTime;
zeit := UTC2Local (zeit);
if checkbox1.Checked = true then begin if CheckBRDSz(now) = true then zeit := IncHour(zeit,1); end;
MDateTime1.SetTime (zeit); MdateTime1.SetSysTime ; application.ProcessMessages; showmessage ('Zeit erfolgreich syncronisiert !!'); except Showmessage ('Fehler beim verbinden'); end; end else Showmessage ('Sie haben keinen Server gewählt !!'); end; |
MdateTime ist eine kompo, die dir das einstellen der systemzeit abnimmt.
Checkbox1 ist beschriftet mit 'Sommer / winterzeit berücksichtigen' und ist standartmässig checked := true !!
Die funktion CheckBRDsz gibts hier www.auq.de/viewtopic.php?t=2926
_________________ In the beginning was the word.
And the word was content-type: text/plain.
|
|
LCS
Beiträge: 1305
Erhaltene Danke: 1
WIN 7, WIN 8
Delphi XE5, Delphi XE, Delphi 2007
|
Verfasst: Mi 16.10.02 09:29
Hi
matze hat folgendes geschrieben: |
Checkbox1 ist beschriftet mit 'Sommer / winterzeit berücksichtigen' und ist standartmässig checked := true !!
Die funktion CheckBRDsz gibts hier www.auq.de/viewtopic.php?t=2926
|
Ja, ja ich weiss. Die ist von mir
Allerdings brauchst du das in dem Fall nicht, weil UTC2Local die Sommer-/Winterzeit ganz automatisch berücksichtigt. Wenn du dann nochmal auf Sommerzeit checkst, ist das sozusagen doppelt gemoppelt. Lass es ganz einfach weg, dann sollte das korrekt funktionieren.
Gruss Lothar
_________________ Der BH ist für die Brust, der Plan ist für'n Ar...
|
|
matze
Beiträge: 4613
Erhaltene Danke: 24
XP home, prof
Delphi 2009 Prof,
|
Verfasst: Mi 16.10.02 15:20
es geht aber immernochnicht !!!
der Code schlägt auf die Zeit immer genau 3 std drauf !!! warum ??
Ich habe mal den Code auf meine server geschoben: www.matze.de.vu/Unit1.pas
PS: Die INcHour und IncMinute habe ich manuell eingefügt, weil die Dateutils bei mir nicht gehen !!! (warum auch immer...)
_________________ In the beginning was the word.
And the word was content-type: text/plain.
|
|
LCS
Beiträge: 1305
Erhaltene Danke: 1
WIN 7, WIN 8
Delphi XE5, Delphi XE, Delphi 2007
|
Verfasst: Do 17.10.02 09:22
Hi matze
ich hab das jetzt mal ausgetestet. Timeserver ptbtime1.ptb.de.
Die Fastnet TNMTime Komponente lieferte 07:16 UTC. Mit der Funktion UTC2Local umgerechnet ergab 09:16.
Die Indy TIdTime Komponente lieferte 09:16 Lokalzeit. Hier scheint also die Umrechnung gleich durch die Komponente gemacht zu werden. Die ganze Umrechnerei kannst du dir also sparen.
Die ganzen Datumsfunktionen befinden sich übrigens bis Delphi 5 in der Unit SysUtils, ab Delphi 6 in der Unit DateUtils. Je nach Version musst du also die eine oder andere in deine Uses-Klausel aufnehmen.
Gruss Lothar
_________________ Der BH ist für die Brust, der Plan ist für'n Ar...
|
|
matze
Beiträge: 4613
Erhaltene Danke: 24
XP home, prof
Delphi 2009 Prof,
|
Verfasst: Do 17.10.02 15:50
Das ist mein einziger kommentar dazu:
_________________ In the beginning was the word.
And the word was content-type: text/plain.
|
|
matze
Beiträge: 4613
Erhaltene Danke: 24
XP home, prof
Delphi 2009 Prof,
|
Verfasst: Do 17.10.02 16:36
AARRRGH !!!
ES GEHT ABER IMMER NOCH NICHT !!! Ich hab jetzt die Routinen rausgenommen und das proggi schlägt immernoch 2 std auf die zeit drauf !!!
Wieso ?? *heul*
_________________ In the beginning was the word.
And the word was content-type: text/plain.
|
|
LCS
Beiträge: 1305
Erhaltene Danke: 1
WIN 7, WIN 8
Delphi XE5, Delphi XE, Delphi 2007
|
Verfasst: Fr 18.10.02 08:35
Schau mal in dein Postfach.
Gruss Lothar
_________________ Der BH ist für die Brust, der Plan ist für'n Ar...
|
|