[英]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++)? 有没有办法通过Win32(在C ++中)格式化适合于语言环境的日期和月份而没有一年? For example, I would like to see 10/31 for the US locale and 31/10 for the UK locale.
例如,我想看到美国语言环境的10/31和英国语言环境的31/10。 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. 我知道
GetDateFormat
接受格式字符串,但是日期和月份被锁定在我在格式字符串中指定的任何位置,这不适合所有语言环境。
You can use GetLocaleInfo
to query the user's date format in order to build your own format string. 您可以使用
GetLocaleInfo
查询用户的日期格式,以便构建自己的格式字符串。
LOCALE_IDATE
returns a value indicating the relative order of day and month, alternatively LOCALE_SSHORTDATE
returns the short date format string. LOCALE_IDATE
返回一个值,指示日期和月份的相对顺序,或者LOCALE_SSHORTDATE
返回短日期格式字符串。 In the latter case you would need to parse this yourself to work out the relative order. 在后一种情况下,您需要自己解析它以计算相对顺序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.