I would like to create a calendar that displays the date based on the calendar weeks. the example works in 2023, but not in 2022, in 2022 the calendar is always shifted back by one week. The problem is probably that January 1, 2022 is in calendar week 52, 2021. how can I solve the problem ?
function getDateOfWeek(w, y,d) {
let date = new Date(y, 0, (1 + (w - 1) * 7));
date.setDate(date.getDate() + (d - date.getDay())); // 0 - Sunday, 1 - Monday etc
console.log(date)
return date
}