Skip to main content

cxGetDateFormat(TDateTime,string,Integer,string) Method

Converts the ADate date into a date string.

Declaration

function cxGetDateFormat(ADate: TDateTime; out AFormatDate: string; AFlags: Integer; const AFormat: string = ''): Boolean;

Parameters

Name Type
ADate TDateTime
AFormatDate string
AFlags Integer
AFormat string

Returns

Type
Boolean

Remarks

Use the cxGetDateFormat function to convert the ADate date into the AFormatDate format string. This function uses the system API to obtain the format string. The cxGetDateFormat function returns a value of True if the host environment supports this operations.

The ADate parameter specifies the date to be converted into the AFormatDate string.

The AFormatDate parameter provides the resulting string which is formatted in accordance with the AFormat date format (if specified) or with the date format of the default user locale.

The AFlags parameter specifies the function’s options. This parameter should be set to 0 if the AFormat parameter is specified. The table below lists the available options:

Value Meaning
LOCALE_NOUSEROVERRIDE If set, the function formats the string using the system default date format for the specified locale. If not set, the function formats the string using any user overrides to the locale’s default date format
LOCALE_USE_CP_ACP Uses the system ANSI code page for string translation instead of the locale’s code page
DATE_SHORTDATE Uses the short date format. This is the default. This value cannot be used with DATE_LONGDATE or DATE_YEARMONTH.
DATE_LONGDATE Uses the long date format. This value cannot be used with DATE_SHORTDATE or DATE_YEARMONTH
DATE_YEARMONTH Uses the year/month format. This value cannot be used with DATE_SHORTDATE or DATE_LONGDATE
DATE_USE_ALT_CALENDAR Uses the alternate calendar (if present) to format the date string. If this flag is set, the function uses the default format for the alternate calendar, rather than any user overrides. The user overrides will be used only in the event that there is no default format for the specified alternate calendar
DATE_LTRREADING Adds marks for left-to-right layout. This value cannot be used with DATE_RTLREADING
DATE_RTLREADING Adds marks for right-to-left layout. This value cannot be used with DATE_LTRREADING

The AFormat parameter specifies the date format. If the AFormat parameter is set to an empty string, then the date format of the default locale is used. The following elements are used to construct the date format:

Value Meaning
d Day of month as digits without a leading zero for single-digit days
dd Day of month as digits with leading zero for single-digit days
ddd Day of week as a three-letter abbreviation
dddd Day of week as its full name
M Month as digits without a leading zero for single-digit months
MM Month as digits with leading zero for single-digit months
MMM Month as a three-letter abbreviation
MMMM Month as its full name
y Year as last two digits, but without a leading zero for years less than 10
yy Year as last two digits, but with leading zero for years less than 10
yyy Year represented by full four digits
gg Period/era string. This element is ignored if the date to be formatted does not have an associated era or period string
See Also