问题
I am very much new to delphi and i tried the following code
procedure TForm1.Button1Click(Sender: TObject);
var
myDate : TDateTime;
day : string;
begin
myDate := EncodeDate(2002, 12, 31);
day := LongDayNames[DayOfWeek(myDate)];
ShowMessage('Christmas day 2002 is on a '+day);
end;
I have declared System.SysUtils
in Uses
section but still i am getting the error Undeclared identifier.
I am using Delphi XE3 17.0
回答1:
In XE2 LongDayNames moved to TFormatSettings. http://docwiki.embarcadero.com/Libraries/XE2/en/System.SysUtils.TFormatSettings.
So you could use:
day := FormatSettings.LongDayNames[DayOfWeek(myDate)];
FormatSettings is a not threadsafe global variable.
How to use it a intended you can see here
来源:https://stackoverflow.com/questions/14018365/sysutils-longdaynames-undeclared-identifier