[Bug 1084431] [NEW] strftime returning date as null on en_IN locale

Launchpad Bug Tracker 1084431 at bugs.launchpad.net
Thu Nov 29 08:30:08 UTC 2012


You have been subscribed to a public bug:

I have one application in which I uses strftime to format the date
returned by localtime_r api into current locale specific format.
strftime works fine with all the locales but for en_IN/en_IN.utf8 locale
it returns the date as null, which is making my application to behave
improperly.

To demonstrate this I have create a small program, which prints the date
in current locale format.

#include <stdio.h>
#include <time.h>
#include <locale.h>

int main ()
{
time_t rawtime=time(NULL);;
struct tm  l_time;
char stime[100]="";
setlocale(LC_ALL,"");
printf ("Locale is: %s\n", setlocale(LC_ALL,NULL) );
time ( &rawtime );
localtime_r(&rawtime,&l_time);
strftime(stime,30,"Date: %x",&l_time);
printf ( "%s\n", stime);
return 0;
}

Now, on my system I have set the locale as en_IN and en_IN.utf8.

root at IWFVM00648:/var/opt/eate/tmp# export LC_ALL=en_IN.utf8
root at IWFVM00648:/var/opt/eate/tmp# export LANG=en_IN.utf8
root at IWFVM00648:/var/opt/eate/tmp# locale
LANG=en_IN.utf8
LANGUAGE=en_IN:en
LC_CTYPE="en_IN.utf8"
LC_NUMERIC="en_IN.utf8"
LC_TIME="en_IN.utf8"
LC_COLLATE="en_IN.utf8"
LC_MONETARY="en_IN.utf8"
LC_MESSAGES="en_IN.utf8"
LC_PAPER="en_IN.utf8"
LC_NAME="en_IN.utf8"
LC_ADDRESS="en_IN.utf8"
LC_TELEPHONE="en_IN.utf8"
LC_MEASUREMENT="en_IN.utf8"
LC_IDENTIFICATION="en_IN.utf8"
LC_ALL=en_IN.utf8
root at IWFVM00648:/var/opt/eate/tmp# ./t
Locale is: en_IN.utf8
Date:                                             ------------------> Date is not coming.

root at IWFVM00648:/var/opt/eate/tmp# export LANG=en_IN
root at IWFVM00648:/var/opt/eate/tmp# export LC_ALL=en_IN
root at IWFVM00648:/var/opt/eate/tmp# ./t
Locale is: en_IN
Date:                                             ------------------> Date is not coming.



Now, the same program I ran with en_US.utf8 and I got the correct date output.

root at IWFVM00648:/var/opt/eate/tmp# export LANG=en_US.utf8
root at IWFVM00648:/var/opt/eate/tmp# export LC_ALL=en_US.utf8
root at IWFVM00648:/var/opt/eate/tmp# locale
LANG=en_US.utf8
LANGUAGE=en_IN:en
LC_CTYPE="en_US.utf8"
LC_NUMERIC="en_US.utf8"
LC_TIME="en_US.utf8"
LC_COLLATE="en_US.utf8"
LC_MONETARY="en_US.utf8"
LC_MESSAGES="en_US.utf8"
LC_PAPER="en_US.utf8"
LC_NAME="en_US.utf8"
LC_ADDRESS="en_US.utf8"
LC_TELEPHONE="en_US.utf8"
LC_MEASUREMENT="en_US.utf8"
LC_IDENTIFICATION="en_US.utf8"
LC_ALL=en_US.utf8
root at IWFVM00648:/var/opt/eate/tmp# ./t
Locale is: en_US.utf8
Date: 11/29/2012
root at IWFVM00648:/var/opt/eate/tmp#


-------------> the same program I have used on other Linux distos, but
there this problem does not shows.


Below are my system details:
Linux IWFVM00648 3.2.0-23-generic #36-Ubuntu SMP Tue Apr 10 20:39:51 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=12.04
DISTRIB_CODENAME=precise
DISTRIB_DESCRIPTION="Ubuntu 12.04 LTS"

Please let me know what can be the possible solution for this.

** Affects: eglibc (Ubuntu)
     Importance: Undecided
         Status: New

-- 
strftime returning date as null on en_IN locale
https://bugs.launchpad.net/bugs/1084431
You received this bug notification because you are a member of Ubuntu Foundations Bugs, which is subscribed to eglibc in Ubuntu.




More information about the foundations-bugs mailing list