此代码应该在 Delphi XE2 中工作,但它在 StrtoDateTime 转换中给出“不是有效的日期和时间”错误:
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;
有什么提示吗?