xdate icon indicating copy to clipboard operation
xdate copied to clipboard

setWeek does not respect UTC mode

Open bspoel opened this issue 8 years ago • 0 comments

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

bspoel avatar Feb 08 '18 09:02 bspoel