Opened 13 years ago

Closed 8 years ago

Last modified 8 years ago

#187 closed defect (fixed)

strftime is broken for several locales

Reported by: guest Owned by: bird
Priority: normal Milestone: libc-0.6.5
Component: libc Version: 0.6.2
Severity: normal Keywords:
Cc: mozilla@…


This is basically what I found out in

strftime gives wrong results for several locales, including en_GB (wrong minutes) and pl_PL (wrong day and month names), and several other eastern European locales (month name replaced with X).

I tested with GCC 3.2.2 and 3.3.5 and both give the same problems.

Attachments (1)

strftime_test.c (721 bytes) - added by guest 13 years ago.
Test for strftime with a few locales that came to mind

Download all attachments as: .zip

Change History (7)

Changed 13 years ago by guest

Attachment: strftime_test.c added

Test for strftime with a few locales that came to mind

comment:1 Changed 13 years ago by guest

Cc: mozilla@… added

Output of the test program:

tryLocale=en_US: buf=Wed Oct 17 20:59:00 CEST 2007 (result=29)
tryLocale=de_DE: buf=Mi 17 Okt 20:59:00 2007 (result=23)
tryLocale=en_GB: buf=Wed 17 Oct 20:20:00 CEST 2007 (result=29)
tryLocale=pl_PL: buf=r. 17 X 2007 20:59:00 (result=22)
tryLocale=cz_CZ: buf=r. 17 X 2007 20:59:00 (result=22)
tryLocale=sk_SK: buf=st 17 X 2007 20:59:00 (result=21)
tryLocale=fi_FI: buf=ke 17 loka 20.59.00 2007 (result=24)
tryLocale=hu_HU: buf=Sze 17 okt. 2007 20:59:00 (result=25)
tryLocale=es_ES: buf=mié oct 17 20:59:00 CEST 2007 (result=29)

For en_GB it should be

   Wed 17 Oct 20:59:00 CEST 2007 [with 59 instead of 20]

instead, for pl_PL

   sr. 17 paz 2007 20:59:00 [with ´ on s and z]

should be correct. The Xs for cz_CZ and sk_SK look suspicious to me, too, but I guess Roman letters are better than something wrong...

Last edited 8 years ago by bird (previous) (diff)

comment:2 Changed 10 years ago by bird

Milestone: libc-0.6.4

comment:3 Changed 9 years ago by bird

Status: newassigned

comment:4 Changed 8 years ago by bird

These bugs comes from C:\OS2\DLL\LOCALE.DLL. There are several strings with %H:%H in there. Seems to be a copy & past bug (c) IBM.

The roman numeral instead of proper month names are probably place holders and they never got around inserting the right data. Unless someone provides me with patches with the UTF-16 formatted strings containing the missing month names, I don't see any other alternative than finding some other locale source (other than LOCALE.DLL).

The reason that cz_CZ doesn't work is that there is no such locale, it's called cs_CZ.

Now, the reason for the funny characters is the same as for #227 and #240. It's pretty obvious (as is the cz_CZ bug mentioned above) if you print the string returned by setlocale(). An FreeBSD 8.2 I happened to have handy does not accept locale without the character set explicitly stated (the testcase does not work at all). As mentioned in #240, I will try change this so that the current process codepage is used when the user does mention a code set in the locale specification.

comment:5 Changed 8 years ago by bird

Resolution: fixed
Status: assignedclosed

Fixed the en_GB date/time format string in r3787.

Closing the defect now. If anyone wants to contribute missing month names, attach the patch and reopen the defect.

comment:6 Changed 8 years ago by bird

r3788 changes the setlocale behavior when no codeset is specified, it now defaults to the process code page.

Note: See TracTickets for help on using tickets.