mde / timezone-js

DEPRECATED: Timezone-enabled JavaScript Date object. Uses Olson zoneinfo files for timezone data.
824 stars 183 forks source link

setTime for UTC time results in incorrect local and UTC time #151

Closed rogierschouten closed 4 years ago

rogierschouten commented 10 years ago

Initializing a timezoneJS UTC Date with setTime() results in a plain incorrect date. I checked d.valueOf() using unixtimestamp.com and the javascript Date returns the correct unix timestamp.

var d: Date = new Date("2014-10-26T01:59:59.000Z");
var t = new timezoneJS.Date("UTC");
t.setTime(d.valueOf());
// FAIL: returns 02:59:59
expect(t.toUTCString()).to.equal("Sun, 26 Oct 2014 01:59:59 GMT"); 
rogierschouten commented 10 years ago

Note my system is set to Europe/Amsterdam so this is within a DST backward change. I don't see how that should affect this UTC-only conversion though.