Time zone offsets for any time zone, possible change to Date functionality (i18n)

Norbert Lindenberg ecmascript at lindenbergsoftware.com
Mon Apr 15 08:46:06 PDT 2013


On Apr 15, 2013, at 5:43 , Dean Landolt wrote:

> On Sun, Apr 14, 2013 at 10:49 PM, Norbert Lindenberg <ecmascript at lindenbergsoftware.com> wrote:
> 
>> I'm afraid this would be quite confusing. Many people believe already that Date instances are in some local time zone, which they aren't, and this would lead even more astray.
> 
> 
> Of course Date instances are in some local timezone -- the timezone of the host system. This data isn't explicitly carried along with each date -- instead it's just more implicit global state. But it's naive and even hazardous to pretend a Date instance has no timezone component -- to say this with a strait face would requiring removing the locale-specific date methods. This is what is leading so many astray. Further, I've found that changing the host timezone can wreak havoc on this implicit state in some environments. I couldn't find anything in the spec about expected behavior but there are subtle but real hazards lurking here.

No, Date instances are in UTC - read the spec.
https://mail.mozilla.org/pipermail/es-discuss/2013-March/028928.html

The time zone of the host system is, as you say, global state. Confusing instance data and global state has real hazards in many areas of software development.

> Previously I'd suggested that Date instances should just own their timezone. Make explicit what's already there implicitly -- slap the system timezone as a symbol on Date.prototype and correct all locale-specific date methods to respect this symbol instead of some hidden global state. Of course this has no impact on a date's underlying value, just on the behavior of its locale methods.

So which one are you proposing: having "Date instances ... own their timezone" or "slap the system timezone as a symbol on Date.prototype and correct all locale-specific date methods to respect this symbol"? These are not the same.

> If you want to alter the timezone used for locale methods on a specific instance just set this property.

Changing the property would affect all instances that have Date.prototype as their prototype, not just "a specific instance".


More information about the es-discuss mailing list