strftime returning date as null on en_IN locale

Bug #1084431 reported by Anshul Goel
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
eglibc (Ubuntu)
New
Undecided
Unassigned

Bug Description

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@IWFVM00648:/var/opt/eate/tmp# export LC_ALL=en_IN.utf8
root@IWFVM00648:/var/opt/eate/tmp# export LANG=en_IN.utf8
root@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@IWFVM00648:/var/opt/eate/tmp# ./t
Locale is: en_IN.utf8
Date: ------------------> Date is not coming.

root@IWFVM00648:/var/opt/eate/tmp# export LANG=en_IN
root@IWFVM00648:/var/opt/eate/tmp# export LC_ALL=en_IN
root@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@IWFVM00648:/var/opt/eate/tmp# export LANG=en_US.utf8
root@IWFVM00648:/var/opt/eate/tmp# export LC_ALL=en_US.utf8
root@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@IWFVM00648:/var/opt/eate/tmp# ./t
Locale is: en_US.utf8
Date: 11/29/2012
root@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: ubuntu → eglibc (Ubuntu)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.