SetCalendarInfoA function

Sets an item of locale information for a calendar. For more information, see Date and Calendar.


BOOL SetCalendarInfoA(
  LCID    Locale,
  CALID   Calendar,
  CALTYPE CalType,
  LPCSTR  lpCalData



Locale identifier that specifies the locale. You can use the MAKELCID macro to create a locale identifier or use one of the following predefined values.

The following custom locale identifiers are also supported.


Calendar identifier for the calendar for which to set information.


Type of calendar information to set. Only the following CALTYPE values are valid for this function. The CAL_USE_CP_ACP constant is only meaningful for the ANSI version of the function.

The application can specify only one calendar identifier per call to this function. An exception can be made if the application uses the binary OR operator to combine CAL_USE_CP_ACP with any valid CALTYPE value defined in Calendar Type Information.


Pointer to a null-terminated calendar information string. The information must be in the format of the specified calendar type.

Return Value

Returns a nonzero value if successful, or 0 otherwise. To get extended error information, the application can call GetLastError, which can return one of the following error codes:

  • ERROR_INTERNAL_ERROR. An unexpected error occurred in the function.
  • ERROR_INVALID_FLAGS. The values supplied for flags were not valid.
  • ERROR_INVALID_PARAMETER. Any of the parameter values was invalid.


This function only affects the user override portion of the calendar settings. It does not set the system defaults.

Calendar information is always passed as a null-terminated Unicode string in the Unicode version of this function, and as a null-terminated ANSI string in the ANSI version. No integers are allowed by this function. Any numeric values must be specified as either Unicode or ANSI text.

When the ANSI version of this function is used with a Unicode-only locale identifier, the function can succeed because the operating system uses the system code page. However, characters that are undefined in the system code page appear in the string as a question mark (?).

CAL_ITWODIGITYEARMAX can be used with any calendar, even if the calendar is not supported for the specified locale. To avoid complications, the application should call EnumCalendarInfo to ensure that the calendar is supported for the locale of interest.


Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header winnls.h (include Windows.h)
Library Kernel32.lib
DLL Kernel32.dll

See Also



National Language Support

National Language Support Functions