toLocaleString() of a date gives wrong results depending on locale

RESOLVED INVALID

Status

()

Core
JavaScript Engine
RESOLVED INVALID
11 years ago
10 years ago

People

(Reporter: Peter Weilbacher, Unassigned)

Tracking

Trunk
x86
OS/2
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

Attachments

(1 attachment)

(Reporter)

Description

11 years ago
User-Agent:       Mozilla/5.0 (OS/2; U; Warp 4.5; en-US; rv:1.9a8pre) Gecko/2007091902 SeaMonkey/2.0a1pre
Build Identifier: Mozilla/5.0 (OS/2; U; Warp 4.5; en-US; rv:1.9a8pre) Gecko/2007091902 SeaMonkey/2.0a1pre

The calcDiff function on the planet page uses then.toLocaleString() to output the current date for the present locale. Depending on locale this doesn't work. 

The input given to the toLocaleString() function currently is
Wed Oct 17 2007 20:59:00 GMT+0200 (CEST)

For de_DE and en_US this correctly outputs
   Mi 17 Okt 20:59:00 2007
   Wed Oct 17 20:59:00 CEST 2007
respectively.

However, for en_GB I get
   Wed 17 Oct 20:20:00 CEST 2007
(note 20:20 instead of the correct 20:59). I also tried pl_PL, there I get
   Žr. 17 X 2007 20:59:00
and while I am no expert in Polish language and dates, I am pretty sure that Poland formats their date differently. Especially the Z char with the circumflex on top is not Polish but Czech, in Polish I think it should be an S with accent on top.

This is broken on at least 1.8 branch and trunk (I tried Firefox 2.0.0.5 on OS/2).

Reproducible: Always
(Reporter)

Comment 1

11 years ago
Created attachment 281558 [details]
reduced testcase

A reduced HTML testcase adapted from the Planet Mozilla page.
(Reporter)

Comment 2

11 years ago
The problem seems to be OS/2 specific. Using the testcase with Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9a9pre) Gecko/2007100201 SeaMonkey/2.0a1pre I get:

Wed Oct 17 2007 20:59:00 GMT+0200 (CEST)
-> en_US: Wed 17 Oct 2007 08:59:00 PM CEST
-> pl_PL: ´sro 17 pa´z 2007 20:59:00 CEST
-> de_DE: Mi 17 Okt 2007 20:59:00 CEST
-> en_GB: Wed Oct 17 20:59:00 2007

all of which seem correct to me.

Can somebody enlighten me where in the JS code I could start debugging this?

Comment 3

11 years ago
http://mxr.mozilla.org/mozilla/source/js/src/jsdate.c#1830

See date_toLocaleString and date_toLocaleHelper.
(Reporter)

Comment 4

11 years ago
OK, thanks Jeff. With that hint I found out that the call to strftime() in PRMJ_FormatTime gives wrong results. So it's most likely a problem of the C-library that comes with OS/2's GCC. I filed a bug with them: http://svn.netlabs.org/libc/ticket/187
(Reporter)

Comment 5

10 years ago
I made a testcase for strftime() which shows the problem and attached it to the bug report for the C-library. So it's not a Mozilla bug. -> invalid
Status: NEW → RESOLVED
Last Resolved: 10 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.