SysUtils.LongDayNames undeclared identifier

僤鯓⒐⒋嵵緔 提交于 2019-12-11 18:33:22

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!