![]() |
Korrespondenz problem- StrToTime und TimeToStr
ich habe fogendes problem:
zu bestimmten ereignissen schreibe ich die zeit millisekunden genau in eine textdatei (wandle Time to string ) und später möchte ich statistik daruber führen (wandle string to time ). doch da passiert etwas nicht naturliches.
Delphi-Quellcode:
mir ist folgendes aufgefallen: StrToTime bekommt den string als 'hh:nn:ss,zzz' aber TimeToStr liefert mir einen string der 'hh:nn:ss:zzz' formatiert ist.
procedure TForm1.test2;
var t1,t2: TDateTime; begin t1 := StrToTime('15:0:34,500', FormatSettings); Caption := TimeToStr(t1,FormatSettings); t2 := StrToTime(Caption, FormatSettings); !!!! hier passiert der fehler. !!!! end; also korrespondieren die zwei funktionen nicht miteinander?! woran liegt das? mein FormatSettings sieht wie folgt aus:
Delphi-Quellcode:
danke für eure hilfe.
GetLocaleFormatSettings(LOCALE_USER_DEFAULT, FormatSettings);
FormatSettings.TwoDigitYearCenturyWindow := 1; FormatSettings.DateSeparator := '.'; FormatSettings.TimeSeparator := ':'; FormatSettings.ShortTimeFormat := 'hh:nn'; FormatSettings.LongTimeFormat := 'hh:nn:ss:zzz'; FormatSettings.ShortDateFormat := ''; FormatSettings.LongDateFormat := ''; |
Re: Korrespondenz problem- StrToTime und TimeToStr
Zitat:
|
Re: Korrespondenz problem- StrToTime und TimeToStr
Delphi-Quellcode:
var t1: TDateTime;
t1 := StrToTime(TimeToStr(Now,FormatSettings), FormatSettings); Den string denn mir TimeToStr schreibt kann ich nicht in wieder mit StrToTime in TDateTime umwandeln. das meine ich mit korrespondez problem. mein FormatSettings sieht immer noch wie folgt aus:
Delphi-Quellcode:
GetLocaleFormatSettings(LOCALE_USER_DEFAULT, FormatSettings);
FormatSettings.TwoDigitYearCenturyWindow := 1; FormatSettings.DateSeparator := '.'; FormatSettings.TimeSeparator := ':'; FormatSettings.ShortTimeFormat := 'hh:nn'; FormatSettings.LongTimeFormat := 'hh:nn:ss:zzz'; // <- hier steht doch, dass du es so interpretiert haben willst FormatSettings.ShortDateFormat := ''; FormatSettings.LongDateFormat := ''; |
Re: Korrespondenz problem- StrToTime und TimeToStr
Hallo,
wirst wohl nicht drumrum kommen, Encode-/DecodeTime zu nutzen. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:31 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