Platform SDK: International Features

EnumDateFormats

The EnumDateFormats function enumerates the long or short date formats that are available for a specified locale. The value of the dwFlags parameter determines whether the long or short date formats are enumerated. The function enumerates the date formats by passing date format string pointers, one at a time, to the specified application defined–callback function. This continues until the last date format is found or the callback function returns FALSE.

To receive a calendar identifier in addition to the date format information provided by EnumDateFormats, use the EnumDateFormatsEx function.

BOOL EnumDateFormats(
  DATEFMT_ENUMPROC lpDateFmtEnumProc, // callback function
  LCID Locale,                        // locale
  DWORD dwFlags                       // date formats
);

Parameters

lpDateFmtEnumProc
[in] Pointer to an application defined–callback function. The EnumDateFormats function enumerates date formats by making repeated calls to this callback function. For more information, see the EnumDateFormatsProc callback function.
Locale
[in] Specifies the locale for which to retrieve date format information. This parameter can be a locale identifier created by the MAKELCID macro, or one of the following predefined values.
Value Meaning
LOCALE_SYSTEM_DEFAULT Default system locale.
LOCALE_USER_DEFAULT Default user locale.

dwFlags
[in] Specifies the date formats of interest. Use one of the following values.
Value Meaning
LOCALE_USE_CP_ACP Uses the system ANSI code page for string translation instead of the locale's code page.
DATE_SHORTDATE Return short date formats. This value cannot be used with DATE_LONGDATE.
DATE_LONGDATE Return long date formats. This value cannot be used with DATE_SHORTDATE.
DATE_YEARMONTH Return year/month formats.

Return Values

If the function succeeds, the return values is a nonzero value.

If the function fails, the return value is zero. To get extended error information, call GetLastError. GetLastError may return one of the following error codes:

Remarks

This function will return all date formats for the specified locale, including alternate calendars, if any. However, the calendar identifier is not returned along with the date format in the callback function, so formats for locales with alternate calendars are difficult to use. To get the date formats for locales with alternate calendars, use EnumDateFormatsEx.

Windows 2000: The ANSI version of this function will fail if it is used with a Unicode-only LCID. See Language Identifiers.

Requirements

  Windows NT/2000: Requires Windows NT 3.5 or later.
  Windows 95/98: Requires Windows 95 or later.
  Header: Declared in Winnls.h; include Windows.h.
  Library: Use Kernel32.lib.
  Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.

See Also

National Language Support Overview, National Language Support Functions, EnumDateFormatsEx, EnumDateFormatsProc, EnumCalendarInfo, EnumTimeFormats