Bug 6716 - strftime(3) does not use LC_TIME or LC_ALL: output always in English
strftime(3) does not use LC_TIME or LC_ALL: output always in English
Status: CLOSED NOTABUG
Product: Red Hat Linux
Classification: Retired
Component: glibc (Show other bugs)
6.0
All Linux
medium Severity medium
: ---
: ---
Assigned To: Cristian Gafton
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 1999-11-04 08:23 EST by bernard
Modified: 2008-05-01 11:37 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2000-02-05 14:23:18 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description bernard 1999-11-04 08:23:09 EST
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 12:47:59 EST
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 06:23:59 EST
===
+#include <locale.h>
+
+setlocale(LC_ALL,"");
===
$ export LANG=fr_FR
Comment 3 bernard 1999-11-22 03:32:59 EST
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 ;-(

Note You need to log in before you can comment on or make changes to this bug.