'How to disable future weeks based on year Angular 8

I have year and weeks dropdown in UI, Based on selected year i am displaying the list of weeks in week dropdown

Now i want to disable future weeks

For Ex - Year 2022, Weeks dropdown showing list of values like 1,2,3,4,.....53 weeks are displaying But i want user can only able to select weeks till current date of February.

Expected output - User can not able to select future weeks or function will display only current weeks numbers not future weeks.

Below is my code which is calculating weeks based on year.

Can anyone please help me to disable future weeks based on my logic.

week(y = 0) {
    y = y ? y : new Date().getFullYear();
    let d, isLeap;
    d = new Date(y, 0, 1);
    isLeap = new Date(y, 1, 29).getMonth() === 1;
    let count = d.getDay() === 4 || isLeap && d.getDay() === 3 ? 53 : 52;
    this.numbers = Array(count).fill(0).map((x, i) => i + 1);
  }


   


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source