@mterry: Your test program seems to give the correct result, but -- what will you do with the 24/12hr information in the end? There is "%R" for a locale-dependent 24h format without seconds but no equivalent for 12h that I'm aware of. Simply using "%I:%M %p" for 12hr locales would not make everyone happy.
I think using translations might actually work if you use a little hack, something along the lines of:
char *message_locale = setlocale(LC_MESSAGES, NULL);
char *time_locale = setlocale(LC_TIME, NULL);
setlocale(LC_MESSAGES, time_locale);
char *time_format = _("%I:%M %p"); /* This will be translated using the PO file corresponding to LC_TIME!*/
setlocale(LC_MESSAGES, message_locale);
@mterry: Your test program seems to give the correct result, but -- what will you do with the 24/12hr information in the end? There is "%R" for a locale-dependent 24h format without seconds but no equivalent for 12h that I'm aware of. Simply using "%I:%M %p" for 12hr locales would not make everyone happy.
I think using translations might actually work if you use a little hack, something along the lines of: LC_MESSAGES, NULL); LC_MESSAGES, time_locale); LC_MESSAGES, message_locale);
char *message_locale = setlocale(
char *time_locale = setlocale(LC_TIME, NULL);
setlocale(
char *time_format = _("%I:%M %p"); /* This will be translated using the PO file corresponding to LC_TIME!*/
setlocale(