mde / timezone-js

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

setTime() function results in wrong UTC and wrong offset but correct local time #150

Closed rogierschouten closed 4 years ago

rogierschouten commented 10 years ago

After applying setTime(), toUTCString() displays a different time:

               // this is within DST backward change in Europe/Amsterdam
        var utc = new timezoneJS.Date(2014, 9, 26, 1, 30, 0, 0, "UTC");
        var local = new timezoneJS.Date("Europe/Amsterdam");
        local.setTime(utc.getTime());
        expect(local.toUTCString()).to.equal("Sun, 26 Oct 2014 01:30:00 GMT");  // FAIL: is now 00:30:00 GMT
        expect(local.getHours()).to.equal(2); // ok
        expect(local.getTimezoneOffset()).to.equal(-60); // FAIL: -120