bestiejs / json3

A JSON polyfill. No longer maintained.
https://bestiejs.github.io/json3
Other
1.02k stars 150 forks source link

Date serialization's timezone handling is broken (seems hardcoded to UTC-06:00) #3

Closed masklinn closed 12 years ago

masklinn commented 12 years ago

The stringify date tests fail in every single browser I tested it in (Firefox 10, Chrome 16, Safari 5.1, Opera 11.61, Camino 2.1.2 [~Firefox 3.6]):

Dates are serialized using the simplified date time string format
    Expected: "\"1994-07-03T06:00:00.000Z\""
    Actual: "\"1994-07-02T22:00:00.000Z\""
The date time string should conform to the format outlined in the spec
    Expected: "\"1993-06-02T08:10:28.224Z\""
    Actual: "\"1993-06-02T00:10:28.224Z\""

This is on OSX 10.6.8 in the Central European Timezone (UTC+01:00).

There are 8h difference between the expected time and the actual time, on both dates the Date object uses CEST (UTC+02:00). I'd expect things to break even more as the timezone is moved further east (e.g. in the Australian timezones, between UTC+08:00 and UTC+11:00) on the testing machine.

ghost commented 12 years ago

Those two tests were, indeed, MDT (UTC-06:00)-specific, as you correctly noted. I've updated them so that they'll check for the general date-time string pattern using a RegExp instead.

Thank you!