GetCalendarInfoA function (winnls.h)

Retrieves information about a calendar for a locale specified by identifier.

Note  For interoperability reasons, the application should prefer the GetCalendarInfoEx function to GetCalendarInfo because Microsoft is migrating toward the use of locale names instead of locale identifiers for new locales. Any application that runs only on Windows Vista and later should use GetCalendarInfoEx.
 

Syntax

int GetCalendarInfoA(
  [in]            LCID    Locale,
  [in]            CALID   Calendar,
  [in]            CALTYPE CalType,
  [out, optional] LPSTR   lpCalData,
  [in]            int     cchData,
  [out, optional] LPDWORD lpValue
);

Parameters

[in] Locale

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

[in] Calendar

Calendar identifier.

[in] CalType

Type of information to retrieve. For more information, see Calendar Type Information.

Note  GetCalendarInfo returns only one string if this parameter specifies CAL_IYEAROFFSETRANGE or CAL_SERASTRING. In both cases the current era is returned.
 
CAL_USE_CP_ACP is relevant only for the ANSI version of this function.

For CAL_NOUSEROVERRIDE, the function ignores any value set by SetCalendarInfo and uses the database settings for the current system default locale. This type is relevant only in the combination CAL_NOUSEROVERRIDE | CAL_ITWODIGITYEARMAX. CAL_ITWODIGITYEARMAX is the only value that can be set by SetCalendarInfo.

[out, optional] lpCalData

Pointer to a buffer in which this function retrieves the requested data as a string. If CAL_RETURN_NUMBER is specified in CalType, this parameter must retrieve NULL.

[in] cchData

Size, in characters, of the lpCalData buffer. The application can set this parameter to 0 to return the required size for the calendar data buffer. In this case, the lpCalData parameter is not used. If CAL_RETURN_NUMBER is specified for CalType, the value of cchData must be 0.

[out, optional] lpValue

Pointer to a variable that receives the requested data as a number. If CAL_RETURN_NUMBER is specified in CalType, then lpValue must not be NULL. If CAL_RETURN_NUMBER is not specified in CalType, then lpValue must be NULL.

Return value

Returns the number of characters retrieved in the lpCalData buffer, with cchData set to a nonzero value, if successful. If the function succeeds, cchData is set to 0, and CAL_RETURN_NUMBER is not specified, the return value is the size of the buffer required to hold the calendar information. If the function succeeds, cchData is set 0, and CAL_RETURN_NUMBER is specified, the return value is the size of the value retrieved in lpValue, that is, 2 for the Unicode version of the function or 4 for the ANSI version.

This function returns 0 if it does not succeed. To get extended error information, the application can call GetLastError, which can return one of the following error codes:

  • ERROR_INSUFFICIENT_BUFFER. A supplied buffer size was not large enough, or it was incorrectly set to NULL.
  • ERROR_INVALID_FLAGS. The values supplied for flags were not valid.
  • ERROR_INVALID_PARAMETER. Any of the parameter values was invalid.

Remarks

Note  This API is being updated to support the May 2019 Japanese era change. If your application supports the Japanese calendar, you should validate that it properly handles the new era. See Prepare your application for the Japanese era change for more information.
 
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 (?).

Note

The winnls.h header defines GetCalendarInfo as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

Requirements

Requirement Value
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

Calendar Type Information

GetCalendarInfoEx

National Language Support

National Language Support Functions

SetCalendarInfo