Defining Calendar Formats

Most locales use the standard Gregorian calendar and a set number of date formats. These default choices for date formats are available for display by using the EnumDateFormats function. Other locales require special considerations when you are creating a complete list of format choices. Some of these require you to insert text strings within the date format string; others require a completely different method of computation of the values. These special requirements are addressed by the addition of certain LCTYPE and CALTYPE values.

Each LCID has a default calendar type associated with it. A locale identifier can also have an alternate calendar type. To have an alternate calendar type for an LCID, you must set LOCALE_IOPTIONALCALENDAR to the alternate calendar type for this locale.

The CALTYPE constants are used in the EnumCalendarInfo and GetCalendarInfo functions to define particular pieces of calendar information. Some of these types are also used for the SetCalendarInfo function.

The following table shows CALTYPE constants that are mutually exclusive—that is, they cannot be used in combination with each other in a function call.

Type
Description
CAL_ICALINTVALUE An integer value indicating the calendar type of the alternate calendar.
CAL_IYEAROFFSETRANGE One or more null-terminated strings that specify the year offsets for each of the era ranges. The last string has an extra terminating null character.
CAL_SABBREVDAYNAME1 Abbreviated local name of the first day of the week.
CAL_SABBREVDAYNAME2 Abbreviated local name of the second day of the week.
CAL_SABBREVDAYNAME3 Abbreviated local name of the third day of the week.
CAL_SABBREVDAYNAME4 Abbreviated local name of the fourth day of the week.
CAL_SABBREVDAYNAME5 Abbreviated local name of the fifth day of the week.
CAL_SABBREVDAYNAME6 Abbreviated local name of the sixth day of the week.
CAL_SABBREVDAYNAME7 Abbreviated local name of the seventh day of the week.
CAL_SABBREVMONTHNAME1 Abbreviated local name of the first month of the year.
CAL_SABBREVMONTHNAME2 Abbreviated local name of the second month of the year.
CAL_SABBREVMONTHNAME3 Abbreviated local name of the third month of the year.
CAL_SABBREVMONTHNAME4 Abbreviated local name of the fourth month of the year.
CAL_SABBREVMONTHNAME5 Abbreviated local name of the fifth month of the year.
CAL_SABBREVMONTHNAME6 Abbreviated local name of the sixth month of the year.
CAL_SABBREVMONTHNAME7 Abbreviated local name of the seventh month of the year.
CAL_SABBREVMONTHNAME8 Abbreviated local name of the eighth month of the year.
CAL_SABBREVMONTHNAME9 Abbreviated local name of the ninth month of the year.
CAL_SABBREVMONTHNAME10 Abbreviated local name of the tenth month of the year.
CAL_SABBREVMONTHNAME11 Abbreviated local name of the eleventh month of the year.
CAL_SABBREVMONTHNAME12 Abbreviated local name of the twelfth month of the year.
CAL_SABBREVMONTHNAME13 Abbreviated local name of the thirteenth month of the year, if it exists.
CAL_SCALNAME Local name of the alternate calendar.
CAL_SDAYNAME1 Local name of the first day of the week.
CAL_SDAYNAME2 Local name of the second day of the week.
CAL_SDAYNAME3 Local name of the third day of the week.
CAL_SDAYNAME4 Local name of the fourth day of the week.
CAL_SDAYNAME5 Local name of the fifth day of the week.
CAL_SDAYNAME6 Local name of the sixth day of the week.
CAL_SDAYNAME7 Local name of the seventh day of the week.
CAL_SERASTRING One or more null-terminated strings that specify each of the Unicode codepoints specifying the era associated with the specified CAL_IYEAROFFSETRANGE. The last string has an extra terminating null character.
CAL_SLONGDATE Long date formats for this calendar type.
CAL_SMONTHNAME1 Local name of the first month of the year.
CAL_SMONTHNAME2 Local name of the second month of the year.
CAL_SMONTHNAME3 Local name of the third month of the year.
CAL_SMONTHNAME4 Local name of the fourth month of the year.
CAL_SMONTHNAME5 Local name of the fifth month of the year.
CAL_SMONTHNAME6 Local name of the sixth month of the year.
CAL_SMONTHNAME7 Local name of the seventh month of the year.
CAL_SMONTHNAME8 Local name of the eighth month of the year.
CAL_SMONTHNAME9 Local name of the ninth month of the year.
CAL_SMONTHNAME10 Local name of the tenth month of the year.
CAL_SMONTHNAME11 Local name of the eleventh month of the year.
CAL_SMONTHNAME12 Local name of the twelfth month of the year.
CAL_SMONTHNAME13 Local name of the thirteenth month of the year, if it exists.
CAL_SSHORTDATE Short date formats for this calendar type.

If the local name for the day of the week or for a month is an empty string, that name is identical to the name given in the corresponding locale information and therefore is not duplicated here.

The CAL_IYEAROFFSETRANGE and CAL_SERASTRING values vary in format, depending on the type of optional calendar. The following example shows the values for these types—for each supported alternate calendar type—along with the formula for how to use the CAL_IYEAROFFSETRANGE value to compute the correct year given the Gregorian current year value Y.

CAL_ICALINTVALUE = "1"
CAL_IYEAROFFSETRANGE = ""
CAL_SERASTRING = ""

CAL_ICALINTVALUE = "2"
CAL_IYEAROFFSETRANGE = ""
CAL_SERASTRING = ""

CAL_ICALINTVALUE = "3"
CAL_IYEAROFFSETRANGE = "1989\01926\01912\01868\0"
CAL_SERASTRING = "Ux337B\0Ux337C\0Ux337D\0Ux337E\0"
if (Y>=1989) { Y = (Y-1989)+1; } 
if (Y>=1926 && Y<1989) { Y = (Y-1926)+1; } 
if (Y>=1912 && Y<1926) { Y = (Y-1912)+1; }
if (Y>=1868 && Y<1912) { Y = (Y-1868)+1; } 
if (Y<1868) { Y = Y; } 

CAL_ICALINTVALUE = "4"
CAL_IYEAROFFSETRANGE = "1912\0"
CAL_SERASTRING = "Ux4E2D\0Ux83EF\0Ux6C11\0Ux570B\0"
if (Y>=1912) { Y = (Y-1912)+1; } 
if (Y<1912) { Y = Y; }

CAL_ICALINTVALUE = "5"
CAL_IYEAROFFSETRANGE = "2333\0"
CAL_SERASTRING = ""
Y = Y+2333;