Emerick Rogul
Emerick Rogul

Reputation: 6804

Format locale-appropriate day and month without year

Is there a way to format a locale-appropriate day and month without a year via Win32 (in C++)? For example, I would like to see 10/31 for the US locale and 31/10 for the UK locale. I know that GetDateFormat accepts a format string, but then the day and month are locked into whatever positions I specify in the format string, which will not be appropriate for all locales.

Upvotes: 1

Views: 85

Answers (1)

Jonathan Potter
Jonathan Potter

Reputation: 37122

You can use GetLocaleInfo to query the user's date format in order to build your own format string.

LOCALE_IDATE returns a value indicating the relative order of day and month, alternatively LOCALE_SSHORTDATE returns the short date format string. In the latter case you would need to parse this yourself to work out the relative order.

Upvotes: 3

Related Questions