Skip to content
This repository was archived by the owner on Apr 14, 2021. It is now read-only.

toLocaleTimeString converts times to GMT #59

Closed
hakanson opened this issue Feb 4, 2014 · 2 comments
Closed

toLocaleTimeString converts times to GMT #59

hakanson opened this issue Feb 4, 2014 · 2 comments

Comments

@hakanson
Copy link

hakanson commented Feb 4, 2014

Running on Chrome (with native Intl support in CST), the following core formats the time of Jan 1, 2013 1:01:01 PM correctly as 1:01 PM

(new Date (2013,0,1,13,1,1)).toLocaleTimeString("en-US", { hour : "numeric", minute : "2-digit",  hour12 : true } )
"1:01 PM"

But, using Intl.js in both Firefox 26.0 and Safari 7.0.1 I get 7:01 PM

(new Date (2013,0,1,13,1,1)).toLocaleTimeString("en-US", { hour : "numeric", minute : "2-digit",  hour12 : true } )
"7:01 PM"

Also affects toLocaleString

(new Date (2013,0,1,23,59,59)).toLocaleString("en-US")
"Wed, Jan 2, 2013, 5:59:59 AM"
@andyearnshaw
Copy link
Owner

At the moment we don't support any time zones, so there's no concept of local time right now. What you're seeing are dates based on UTC. Time zones are coming, but I switched to using UTC Date.prototype methods based on #52 and Norbert's comment in #19, which is why you're seeing the issue now.

I've just about finished working out all the kinks in the Sauce Labs test suite, so I'm hoping to get around to this very soon.

@andyearnshaw
Copy link
Owner

Thinking on this a bit more, I might revert to the old method of getting time components, unless the user specifies { timeZone: 'UTC' }. The main reason for this is that I'm still unsure how to tackle adding the IANA tz data for browsers, and I need a bit more time to mull it over and play around.

The downside is that we'll be following the "goofy rules" (as @NorbertLindenberg put it) for time zone handling the time being.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants