Questo codice dovrebbe funzionare in Delphi XE2, ma dà "non è una data valida e l'ora" Errore nella conversione StrtoDateTime:conversione con StrToDateTime e TFormatSettings non funziona
procedure TForm2.Button1Click(Sender: TObject);
var
s: string;
d: TDateTime;
FmtStngs: TFormatSettings;
begin
GetLocaleFormatSettings(GetThreadLocale, FmtStngs);
FmtStngs.DateSeparator := #32;
FmtStngs.ShortDateFormat := 'dd mmm yyyy';
FmtStngs.TimeSeparator := ':';
FmtStngs.LongTimeFormat := 'hh:nn';
s := FormatDateTime('', Now, FmtStngs);
d := StrToDateTime(s, FmtStngs);
end;
Eventuali suggerimenti?
BTW: Il DateSeparator viene utilizzato solo per cambiare il '/' in Format-String. Per utilizzarlo è necessario impostare ShortDateFormat su 'gg/mm/aaaa' altrimenti non è utile: o) –