GetDateFormat returning invalid short date for ky-KG (Kyrgyz - Kyrgyzstan)

Viewed 23

Windows reports that the "short date" format (LOCALE_SShortDate) for ky-KG is:

d-MMM yy

The date format string contains picture codes. Other pictures codes are d, dd, ddd, dddd, M, MM, MMM, MMMM, yy, yyyy.

For english people, the resulting string that uses that date format would be:

16-Oct 21
\/ \_/ \/
d  MMM yy

Because MMM is taken to mean the "Abbreviated month as specified by a LOCALE_SABBREVMONTHNAME value, for example, "Oct" in English (United States)."*

And for English locales, those "abbreviated month names" would be:

Locale Info Value
LOCALE_SABBREVMONTHNAME1 Jan
LOCALE_SABBREVMONTHNAME2 Feb
LOCALE_SABBREVMONTHNAME3 Mar
LOCALE_SABBREVMONTHNAME4 Apr
LOCALE_SABBREVMONTHNAME5 May
LOCALE_SABBREVMONTHNAME6 Jun
LOCALE_SABBREVMONTHNAME7 Jul
LOCALE_SABBREVMONTHNAME8 Aug
LOCALE_SABBREVMONTHNAME9 Sep
LOCALE_SABBREVMONTHNAME10 Oct
LOCALE_SABBREVMONTHNAME11 Nov
LOCALE_SABBREVMONTHNAME12 Dec

You can use the GetDateFormat function to return you a date that follows the abbreviated month names for English.

So to format a date with the format string of d-MMM yy, using the en-US locale you would call something like: (pseudocode)

GetDateFormat(1033, LOCALE_NOUSEROVERRIDE, &systemTime, "d-MMM yy", buffer, bufferLen);

Returning a formatted string of the form:

  • 16-Oct 21
    d.MMM yy

Now for Kyrgyzstan

Kyrgyz uses different abbreviations for its months; which makes sense since they don't speak English:

Locale Info Value
LOCALE_SABBREVMONTHNAME1 янв
LOCALE_SABBREVMONTHNAME2 фев
LOCALE_SABBREVMONTHNAME3 мар
LOCALE_SABBREVMONTHNAME4 апр
LOCALE_SABBREVMONTHNAME5 май
LOCALE_SABBREVMONTHNAME6 июн
LOCALE_SABBREVMONTHNAME7 июл
LOCALE_SABBREVMONTHNAME8 авг
LOCALE_SABBREVMONTHNAME9 сен
LOCALE_SABBREVMONTHNAME10 окт
LOCALE_SABBREVMONTHNAME11 ноя
LOCALE_SABBREVMONTHNAME12 дек

When i try the same call to GetDateFormat for the ky-KG locale:

GetDateFormat(1088, LOCALE_NOUSEROVERRIDE, &systemTime, "d-MMM yy", buffer, bufferLen);

I get a resulting formatted date string of:

  • 16-окт. 21
             ^

Notice the extra . in there.

That doesn't match the short date format string:

  • Expected: d-MMM yy
  • Actual: d-MMM. yy

It's a bug, but how to work around it?

If Windows is telling me:

  • that the "short date format" is d-MMM yy
  • and that the abbreviated name of Октябрь is окт
  • and Windows provides the function to format a date using those strings

Why is Windows generating a string that Windows says the string should look like?

It's a pain when you try to parse a date generated by Windows, and that date generated by Windows does not match the format the Windows says the format should be.

What is going on, and how do i fix it in a locale neutral-way?

Windows 10.0.19043.1237

Bonus Chatter

Kyrgyzstan is the only locale that doesn't use MM (i.e. numbers) in their short date.

Bulgaria and Turkmenistan have a short date format that includes fixed suffixes:

  • Bulgaria: d.M.yyyy 'г.'
  • Turkmenistan: dd.MM.yy 'ý.'

Neat! I don't know what the suffix abbreviations stand for; but it's just neat to see.

Bonus Reading

0 Answers
Related