AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Cross-Platform-Entwicklung Umrechnung UTC in lokale Zeit plattformabhängig?
Thema durchsuchen
Ansicht
Themen-Optionen

Umrechnung UTC in lokale Zeit plattformabhängig?

Ein Thema von bra · begonnen am 23. Feb 2016 · letzter Beitrag vom 24. Feb 2016
 
bra

Registriert seit: 20. Jan 2015
711 Beiträge
 
Delphi 10.2 Tokyo Enterprise
 
#1

Umrechnung UTC in lokale Zeit plattformabhängig?

  Alt 23. Feb 2016, 13:52
Ich bin mal wieder auf ein Problem gestoßen und weiss nicht, ob das ein Problem von Delphi ist oder der jeweiligen Plattform:

Folgender Code:

Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
const
  c1900T1700 = '1900-01-01T17:00:00.000Z';
  c1950T1700 = '1950-01-01T17:00:00.000Z';
  c1970T1700 = '1970-01-01T17:00:00.000Z';
  c1990T1700 = '1990-01-01T17:00:00.000Z';
  c2016T1700 = '2016-01-01T17:00:00.000Z';
  c1900T1700a = '1900-07-01T17:00:00.000Z';
  c1950T1700a = '1950-07-01T17:00:00.000Z';
  c1970T1700a = '1970-07-01T17:00:00.000Z';
  c1990T1700a = '1990-07-01T17:00:00.000Z';
  c2016T1700a = '2016-07-01T17:00:00.000Z';
  cGerman = 'dd.mm.yyyy hh:nn:ss';
begin
  Memo1.Lines.Clear;
  Memo1.Lines.Add('Winterzeit UTC');
  Memo1.Lines.Add(Format('%s -> %s', [c1900T1700, FormatDateTime(cGerman, ISO8601ToDate(c1900T1700))]));
  Memo1.Lines.Add(Format('%s -> %s', [c1950T1700, FormatDateTime(cGerman, ISO8601ToDate(c1950T1700))]));
  Memo1.Lines.Add(Format('%s -> %s', [c1970T1700, FormatDateTime(cGerman, ISO8601ToDate(c1970T1700))]));
  Memo1.Lines.Add(Format('%s -> %s', [c1990T1700, FormatDateTime(cGerman, ISO8601ToDate(c1990T1700))]));
  Memo1.Lines.Add(Format('%s -> %s', [c2016T1700, FormatDateTime(cGerman, ISO8601ToDate(c2016T1700))]));
  Memo1.Lines.Add('Sommerzeit UTC');
  Memo1.Lines.Add(Format('%s -> %s', [c1900T1700a, FormatDateTime(cGerman, ISO8601ToDate(c1900T1700a))]));
  Memo1.Lines.Add(Format('%s -> %s', [c1950T1700a, FormatDateTime(cGerman, ISO8601ToDate(c1950T1700a))]));
  Memo1.Lines.Add(Format('%s -> %s', [c1970T1700a, FormatDateTime(cGerman, ISO8601ToDate(c1970T1700a))]));
  Memo1.Lines.Add(Format('%s -> %s', [c1990T1700a, FormatDateTime(cGerman, ISO8601ToDate(c1990T1700a))]));
  Memo1.Lines.Add(Format('%s -> %s', [c2016T1700a, FormatDateTime(cGerman, ISO8601ToDate(c2016T1700a))]));

  Memo1.Lines.Add('Winterzeit lokal');
  Memo1.Lines.Add(Format('%s -> %s', [c1900T1700, FormatDateTime(cGerman, TTimeZone.Local.ToLocalTime(ISO8601ToDate(c1900T1700)))]));
  Memo1.Lines.Add(Format('%s -> %s', [c1950T1700, FormatDateTime(cGerman, TTimeZone.Local.ToLocalTime(ISO8601ToDate(c1950T1700)))]));
  Memo1.Lines.Add(Format('%s -> %s', [c1970T1700, FormatDateTime(cGerman, TTimeZone.Local.ToLocalTime(ISO8601ToDate(c1970T1700)))]));
  Memo1.Lines.Add(Format('%s -> %s', [c1990T1700, FormatDateTime(cGerman, TTimeZone.Local.ToLocalTime(ISO8601ToDate(c1990T1700)))]));
  Memo1.Lines.Add(Format('%s -> %s', [c2016T1700, FormatDateTime(cGerman, TTimeZone.Local.ToLocalTime(ISO8601ToDate(c2016T1700)))]));
  Memo1.Lines.Add('Sommerzeit lokal');
  Memo1.Lines.Add(Format('%s -> %s', [c1900T1700a, FormatDateTime(cGerman, TTimeZone.Local.ToLocalTime(ISO8601ToDate(c1900T1700a)))]));
  Memo1.Lines.Add(Format('%s -> %s', [c1950T1700a, FormatDateTime(cGerman, TTimeZone.Local.ToLocalTime(ISO8601ToDate(c1950T1700a)))]));
  Memo1.Lines.Add(Format('%s -> %s', [c1970T1700a, FormatDateTime(cGerman, TTimeZone.Local.ToLocalTime(ISO8601ToDate(c1970T1700a)))]));
  Memo1.Lines.Add(Format('%s -> %s', [c1990T1700a, FormatDateTime(cGerman, TTimeZone.Local.ToLocalTime(ISO8601ToDate(c1990T1700a)))]));
  Memo1.Lines.Add(Format('%s -> %s', [c2016T1700a, FormatDateTime(cGerman, TTimeZone.Local.ToLocalTime(ISO8601ToDate(c2016T1700a)))]));
end;
Liefert auf Windows, iOS und Android jeweils andere Ergebnisse (alle auf MEZ eingestellt):

Windows:
Winterzeit UTC
1900-01-01T17:00:00.000Z -> 01.01.1900 17:00:00
1950-01-01T17:00:00.000Z -> 01.01.1950 17:00:00
1970-01-01T17:00:00.000Z -> 01.01.1970 17:00:00
1990-01-01T17:00:00.000Z -> 01.01.1990 17:00:00
2016-01-01T17:00:00.000Z -> 01.01.2016 17:00:00
Sommerzeit UTC
1900-07-01T17:00:00.000Z -> 01.07.1900 17:00:00
1950-07-01T17:00:00.000Z -> 01.07.1950 17:00:00
1970-07-01T17:00:00.000Z -> 01.07.1970 17:00:00
1990-07-01T17:00:00.000Z -> 01.07.1990 17:00:00
2016-07-01T17:00:00.000Z -> 01.07.2016 17:00:00
Winterzeit lokal
1900-01-01T17:00:00.000Z -> 01.01.1900 18:00:00
1950-01-01T17:00:00.000Z -> 01.01.1950 18:00:00
1970-01-01T17:00:00.000Z -> 01.01.1970 18:00:00
1990-01-01T17:00:00.000Z -> 01.01.1990 18:00:00
2016-01-01T17:00:00.000Z -> 01.01.2016 18:00:00
Sommerzeit lokal
1900-07-01T17:00:00.000Z -> 01.07.1900 19:00:00
1950-07-01T17:00:00.000Z -> 01.07.1950 19:00:00
1970-07-01T17:00:00.000Z -> 01.07.1970 19:00:00
1990-07-01T17:00:00.000Z -> 01.07.1990 19:00:00
2016-07-01T17:00:00.000Z -> 01.07.2016 19:00:00


iOS:
Winterzeit UTC
1900-01-01T17:00:00.000Z -> 01.01.1900 17:00:00
1950-01-01T17:00:00.000Z -> 01.01.1950 17:00:00
1970-01-01T17:00:00.000Z -> 01.01.1970 17:00:00
1990-01-01T17:00:00.000Z -> 01.01.1990 17:00:00
2016-01-01T17:00:00.000Z -> 01.01.2016 17:00:00
Sommerzeit UTC
1900-07-01T17:00:00.000Z -> 01.07.1900 17:00:00
1950-07-01T17:00:00.000Z -> 01.07.1950 17:00:00
1970-07-01T17:00:00.000Z -> 01.07.1970 17:00:00
1990-07-01T17:00:00.000Z -> 01.07.1990 17:00:00
2016-07-01T17:00:00.000Z -> 01.07.2016 17:00:00
Winterzeit lokal
1900-01-01T17:00:00.000Z -> 01.01.1900 18:00:00
1950-01-01T17:00:00.000Z -> 01.01.1950 18:00:00
1970-01-01T17:00:00.000Z -> 01.01.1970 18:00:00
1990-01-01T17:00:00.000Z -> 01.01.1990 18:00:00
2016-01-01T17:00:00.000Z -> 01.01.2016 18:00:00
Sommerzeit lokal
1900-07-01T17:00:00.000Z -> 01.07.1900 18:00:00
1950-07-01T17:00:00.000Z -> 01.07.1950 18:00:00
1970-07-01T17:00:00.000Z -> 01.07.1970 18:00:00
1990-07-01T17:00:00.000Z -> 01.07.1990 19:00:00
2016-07-01T17:00:00.000Z -> 01.07.2016 19:00:00

Android:
Winterzeit UTC
1900-01-01T17:00:00.000Z -> 01.01.1900 17:00:00
1950-01-01T17:00:00.000Z -> 01.01.1950 17:00:00
1970-01-01T17:00:00.000Z -> 01.01.1970 17:00:00
1990-01-01T17:00:00.000Z -> 01.01.1990 17:00:00
2016-01-01T17:00:00.000Z -> 01.01.2016 17:00:00
Sommerzeit UTC
1900-07-01T17:00:00.000Z -> 01.07.1900 17:00:00
1950-07-01T17:00:00.000Z -> 01.07.1950 17:00:00
1970-07-01T17:00:00.000Z -> 01.07.1970 17:00:00
1990-07-01T17:00:00.000Z -> 01.07.1990 17:00:00
2016-07-01T17:00:00.000Z -> 01.07.2016 17:00:00
Winterzeit lokal
1900-01-01T17:00:00.000Z -> 01.01.1900 17:00:00
1950-01-01T17:00:00.000Z -> 01.01.1950 17:00:00
1970-01-01T17:00:00.000Z -> 01.01.1970 18:00:00
1990-01-01T17:00:00.000Z -> 01.01.1990 18:00:00
2016-01-01T17:00:00.000Z -> 01.01.2016 18:00:00
Sommerzeit lokal
1900-07-01T17:00:00.000Z -> 01.07.1900 17:00:00
1950-07-01T17:00:00.000Z -> 01.07.1950 17:00:00
1970-07-01T17:00:00.000Z -> 01.07.1970 18:00:00
1990-07-01T17:00:00.000Z -> 01.07.1990 19:00:00
2016-07-01T17:00:00.000Z -> 01.07.2016 19:00:00


Ist das jetzt ein Problem der Delphi-Routine TTimeZone.Local.ToLocalTime oder liefern hier die einzelnen Plattformen unterschiedliche Zeitzonen-Informationen zurück?
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 14:36 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 by Thomas Breitkreuz