arshaw / xdate

A Modern JavaScript Date Library
http://arshaw.com/xdate/
GNU General Public License v2.0
681 stars 81 forks source link

setWeek does not respect UTC mode #38

Open bspoel opened 6 years ago

bspoel commented 6 years ago

When I set the weeknumber of a UTC-mode xdate, it reverts to my current time zone.

let date = new XDate(true); date.setHours(0).setMinutes(0).setSeconds(0).setMilliseconds(0); console.log(date); // {0: Thu, 08 Feb 2018 00:00:00 GMT} date.setWeek(date.getWeek()); console.log(date); // Expected: {0: Mon, 05 Feb 2018 00:00:00 GMT} // Actual: {0: Sun, 04 Feb 2018 23:00:00 GMT}

Tested on Chrome.

Workaround: use setUTCWeek() instead