Bug 6716 - strftime(3) does not use LC_TIME or LC_ALL: output always in English
Summary: strftime(3) does not use LC_TIME or LC_ALL: output always in English
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: glibc
Version: 6.0
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Cristian Gafton
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 1999-11-04 13:23 UTC by bernard
Modified: 2008-05-01 15:37 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2000-02-05 19:23:18 UTC


Attachments (Terms of Use)

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 ;-(


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