Closed Bug 158328 Opened 22 years ago Closed 7 years ago

Date.to___String() problems w Daylight Savings Time in U.K.

Categories

(Core :: JavaScript Engine, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: john, Unassigned)

References

()

Details

From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.0) Gecko/20020606
BuildID:    2002060615

It appears Date.toLocaleString gets the time zone wrong.

I've found that (in the UK, where we're on BST, British Summer Time, which is a
daylight savings time 1 hour ahead of GMT) I get times returned as BST, but
claiming to be GMT when I call toLocaleString().

So, if I start off with a time:

Fri, 19 Jul 2002 15:49:46 GMT

Put it into a Date object with something like:

thing = new Date;
thing.setTime(Date.parse("Fri, 19 Jul 2002 15:49:46 GMT");

and then do:

document.write(thing.toLocaleString());

I get:

Fri 19 Jul 2002 16:49:46 GMT

So, it's correctly localised it, and given me a BST time, but it says _GMT_ for
the timezone.

I've now noticed that the same holds for Date.toString(), which in this case
returns:

Fri Jul 19 2002 16:49:46 GMT+0100 (GMT)

which is a very odd format.

The URL in the bug has a test page that shows the problem...I'm guessing it'll
work for anyone on DST.


Reproducible: Always
Steps to Reproduce:
1. Go to URL
2. Look at webpage, specifically the line that starts "Locale String:"



Actual Results:  Fri 19 Jul 2002 16:49:46 GMT

Expected Results:  Fri 19 Jul 2002 16:49:46 BST
The results on Windows Mozilla are:
toLocaleString()   Friday, July 19, 2002 16:49:46

manages to be OK, because it doesn't display the timezone.

toString()         Fri Jul 19 2002 16:49:46 GMT+0100 (GMT Daylight Time)

which I guess is right, as long as the "GMT+0100" isn't telling you to add an
hour to the time, and instead just telling your current timezone is GMT+0100
(odd it doesn't know about BST).
> which I guess is right, as long as the "GMT+0100" isn't telling you
> to add an hour to the time, and instead is just telling your current
> timezone is GMT+0100 (odd it doesn't know about BST).

Correct; the GMT+0100 is simply indicating showing the offset of
your datestring from what that datestring would look like in GMT.


It looks right to me for Date.toString() to say "GMT+0100 (GMT Daylight Time)". 
There are other locales in the same timezone as the U.K., and it would be
wrong to use a country-specific term such as "BST" for those locales.

For Date.toLocaleString(), on the other hand, you're right: on Windows
we're getting away with not indicating "BST" or anything else!


On Linux, we have a more serious problem, as reported above. During 
the Daylight Savings Time period, perhaps we should do as on Windows:

ie. for Date.toString():    not "GMT+0100 (GMT)"  as we're doing now 
                            but "GMT+0100 (GMT Daylight Time)"

for Date.toLocaleString():  not "GMT"  as we're doing now
                            but "BST"  in the U.K. locale



Note the related bug 61184 on the Mac,
"Date.prototype.toLocale___String() functions : GMT error"

And bug 65671 on Linux,
"JS (SpiderMonkey) Date() timezone problems on UNIX platforms"
Assignee: rogerl → khanson
Status: UNCONFIRMED → NEW
Ever confirmed: true
Summary: Date.toLocaleString() gets time zone wrong → Date.to___String() problems w Daylight Savings Time in U.K.
Further investigation shows that toLocaleString() and toString() are working for
a lot of timezones, just not Britain's...

I've tried:

TZ=America/New_York
TZ=America/Los_Angeles
TZ=Europe/Berlin
TZ=Asia/Jakarta
This is still apparent on Firefox 1.0, more than 2 years after the report.

I've just fixed up the test page, you can type any date into the field so you
can try different times.
Assignee: khanson → general
QA Contact: pschwartau → general
Also still apparent on Firefox 3.0.2 on Linux:

Locale string: Fri 19 Jul 2002 16:49:46 GMT
GMT string: Fri, 19 Jul 2002 15:49:46 GMT
UTC string: Fri, 19 Jul 2002 15:49:46 GMT
String: Fri Jul 19 2002 16:49:46 GMT+0100 (GMT)
I'm seeing the opposite problem on Mac OS X (10.4.11, if it matters), I think. It's currently December, so British Summer Time is not in effect, but Firefox 3.5.6 reports the timezone as "GMT+0000 (BST)". It should display "GMT+0000 (GMT)", I think. It should only say "BST" when BST is actually in effect, but it says BST all year apparently. The "date" command executed in "Terminal" window gets the timezone right ("GMT"), so it seems as though Firefox is confused about daylight savings time somehow.
Blocks: 425901
Assignee: general → nobody
No longer reproducible for me (with or without https://hg.mozilla.org/mozilla-central/rev/b7ef07909cc4), therefore marking as WFM.
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.