Skip to content
This repository has been archived by the owner on Jan 26, 2020. It is now read-only.

Dates are off in timezones that use DST #58

Closed
mattjohnsonpint opened this issue Feb 9, 2013 · 2 comments
Closed

Dates are off in timezones that use DST #58

mattjohnsonpint opened this issue Feb 9, 2013 · 2 comments

Comments

@mattjohnsonpint
Copy link

Consider the following:

var ts1 = 1383451200000;
var dt = new timezoneJS.Date(ts1, 'America/New_York');
var ts2 = dt.getTime();

I would expect that ts2 would be equal to ts1 regardless of which timezone I provided, because they are supposed to be UTC. Instead, ts1 is 1383447600000

If I switch to a timezone that doesn't use DST, such as America/Phoenix or Asia/Kolkata then it works as expected.

Or am I wrong in thinking that the input or the output is supposed to be in UTC? The documentation isn't very clear about that. Thanks.

@divide0
Copy link
Contributor

divide0 commented Feb 10, 2013

Your understanding is mostly correct. getTime/setTime works on milliseconds from the Unix epoch. Timezones shouldn't come into it until you try to print out a time in HH:mm:ss format.

There are bugs in timezone-js when you have dates near the DST transitions. It has trouble identifying the correct DST rule to use.

@io41
Copy link

io41 commented Apr 18, 2013

I think this used to work though. See #78

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

4 participants