These functions work by counting how many Thursdays have occurred up to this date
function formatUTCWeekNumberISO(d, p) { d = UTCdISO(d); return pad(utcThursday.count(utcYear(d), d) + (utcYear(d).getUTCDay() === 4), p, 2); }
Unfortunately the argument d is re-assigned and can cause the year to roll over, so that utcYear(d) returns a different year because UTC is in a different timezone
Codepen: https://codepen.io/28raining/pen/VwqYaKL?editors=1111
Using a separate variable avoids this
function formatUTCWeekNumberISO(d, p) { var dUTC = UTCdISO(d); return pad(utcThursday.count(utcYear(d), dUTC ) + (utcYear(d).getUTCDay() === 4), p, 2); }