arshaw / xdate

A Modern JavaScript Date Library

Home Page:http://arshaw.com/xdate/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

setWeek does not respect UTC mode

bspoel opened this issue · 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