Closed danielrichman closed 12 years ago
Yeah initially I was thinking of the constructor where the last arg is tz
and the rest are params corresponding to that tz
but it seems to make more sense that when you pass in a utcMillis
it should be in Etc/UTC
. I'll take a look at this.
I've since had a stab at modifying the constructor. It's not finished (need to add some more tests), but after modifying the unit test that I linked too, the changes still pass all the others
https://github.com/danielrichman/timezone-js/commit/60afd176d47fbf41fedfd844c31c41ba6e885a6f
This comes down to the assumption of how we construct timezoneJS.Date object:
utcMillis
would be off (2012-08-01 00:00:00 UTC does not have the same utcMillis
as 2012-08-01 00:00:00 EST).utcMillis
is fixed, then year, month, date... would be off.I think for now the library sticks with the 1st assumption, so new Date(0) is 1970-01-01 UTC but same date in EST would be -5 * 3600 * 1000
fixed in e401a597e
date.js lists this as a possible way to construct a date: timezoneJS.Date(utcMillis, [tz]): Return object with UTC time = utcMillis, in tz and states that getTime() returns UTC time.
However:
I'm not sure if I've badly misinterpreted the documentation or this is broken. Indeed, this behaviour is even unit tested.
Some strange implications of this behaviour:
Finally, noting that my system/browser time is set to Europe/London;
but I would expect all five of these numbers to be the same (the correct UNIX timestamp when I ran that was 1342526932)