[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Internationalization in strftime



On Thu, Nov 02, 2006 at 02:12:37PM +0000, César Enrique García Dabó wrote:
>  Hi, I am using the function strftime to output localized dates. However, the 
> localization is properly done.

A "not" is missing here.

Whenever a program starts it uses the locale "C". You need to change it
as follows:

>  I am using the following test program:
> #include <time.h>
> #include <stdio.h>

#include <locale.h>
 
> main()
> {
    setlocale(LC_ALL, "");
>   struct tm time;
>   char string[1000];
>   time.tm_mday = 2;
>   time.tm_mon = 10;
>   time.tm_year = 106;
>   strftime(string, 999, "%d/%B/%Y",&time);
>   printf(" Localized time: %s\n",string);
> }
> 
>  In theory, the %B format should print the month in localized form. I am using 
> es_ES locale but I get the following:
>  Localized time: 02/November/2006
> 
> while the comand "date +%d/%B/%Y" outputs the date well localized:
> 02/noviembre/2006

It a bad date to test in in German since I expect the same for German
and English:
Localized time: 02/November/2006
 
> DISCLAIMER: This message is intended exclusively for its addressee and may contain information that is CONFIDENTIAL and protected by professional privilege. If you are not the intended recipient you are hereby notified that any dissemination, copy or disclosure of this communication is strictly prohibited by law. If this message has been received in error, please immediately notify us via e-mail to GRAN TELESCOPIO DE CANARIAS, S.A. (gtc@gtc.iac.es) and delete it.

DON'T SEND SUCH STUPID DISCLAIMERS TO PUBLIC LISTS! What if someone
standing behind me reads this mail. Now he never is allowed to talk
about the content and always has to remember where he learned some
facts. In such ugly mails as yours or somewhere else?

Jens



Reply to: