Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.

Bug 6716

Summary: strftime(3) does not use LC_TIME or LC_ALL: output always in English
Product: [Retired] Red Hat Linux Reporter: bernard
Component: glibcAssignee: Cristian Gafton <gafton>
Status: CLOSED NOTABUG QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 6.0CC: bernard, pbrown
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2000-02-05 19:23:18 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Description bernard 1999-11-04 13:23:09 UTC
Hi there.

When one uses strftime(3) to get a date string formated
according to one's need, locale is not taken into account:
the week day and month name are still in English.

When one strace(1) a process that uses strftime(3), one can
see that no access is done to open locale files.

Examination of the source of strftime in glibc2 shows that
the problem comes probably of a bad configuration of the
GLIBC since strftime.c seems to be able to get locale thru
_NL_CURRENT macro if correctly compiled.

I did not report the bug to FSF/GNU yet because of that.

Example of program showing the bug:

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

main()
{
  time_t Now=time(NULL);
  struct tm MyTm;
  char String[100];

  memcpy(&MyTm,locatime(&Now),sizeof(struct tm));
  strftime(String,sizeof(String)-1,"%A",&MyTm);
  printf("String=[%s]\n",String);
}

Run this program with LC_TIME=fr_FR (for instance) and
you'll see still English output.

strace this program and you'll see no file opened to get
the locale.

Same problem with RedHat 6.1

Thanks for your help.

Comment 1 Preston Brown 1999-11-15 17:47:59 UTC
as far as I know, you have to call setlocale(getenv("LC_ALL")) before you can
use localized functions.

Comment 2 Alec Voropay 1999-11-21 11:23:59 UTC
===
+#include <locale.h>
+
+setlocale(LC_ALL,"");
===
$ export LANG=fr_FR

Comment 3 bernard 1999-11-22 08:32:59 UTC
Thanks guys. Being used to USVR4 where strftime(3) did not need any explicit
call to setlocale(3) before its use, I reported a non-bug ;-(