FormatDateTimeLCID formats a value of type TDateTime, taking into account the language-specific formatting of the specified LCID.
The way of formatting is read out by the operating system. Whether the specified LCID is supported or whether the desired result is obtained depends solely on the settings of the operating system. These can be viewed under "Control Panel/Region and Language Options".
function FormatDateTimeLCID(const Format: string;
DateTime: TDateTime; LCID:Integer): string;
FormatDateTime formats a value of type TDateTime (DateTime). The format specified with Format is used. An overview of the possibilities of format can be found here. The parameter LCID, which is also passed in this function, determines the country-specific formatting. This allows you, for example, to generate a date formatting for the French language area in a Windows set for Germany. Table LCID gives you all values defined in Windows.
var S : String; d : TDateTime; begin d:=StrToDateTime('25.10.2001 15:35:08'); S:=FormatDateTimeLCID('dddd", " dd. '+ 'mmmm yyyy "Time:" hh:mm',d,1033); ShowMessage(s); end;
Rules to understand the script can be found here.
The date variable d is assigned the date '25.10.2001 15:35:08' via the conversion function StrToDateTime. Then the date variable is formatted and assigned to the string S via FormatDateTime.
In the format mask, the day of the week is the first thing called up by dddd. The fixed text is enclosed in double quotation marks. The month name is retrieved via mmmm. Since the function line in this example would have been too long, we split the format text into two parts and concatenated it with a +. Of course, the format text would also work as one line:
'dddd", " dd. mmmm yyyy "Time:" hh:mm'
As last parameter the LCID with the value 1033 was passed. This stands for an"English (US)" specific edition. The example naturally contains fixed text in German, so that the output contains mixed language elements. However, this best illustrates the effect.