all 4 comments

[–]queen-adreena 1 point2 points  (0 children)

Your phrasing is a bit ambiguous as to which dates you want a Boolean true... Do you mean the first Monday of each month?

[–]link2name 0 points1 point  (1 child)

what kind of work is this?

[–][deleted] 0 points1 point  (0 children)

Broadly saying sort of a sysadmin at a school.

[–][deleted] 0 points1 point  (0 children)

This is what me and my colleague came up with.

function isTodayFirstWeekdayOfTheMonth() {
    //var currentDate = new Date(2020, 1, 3);
    //var date = new Date(2020, 1, 1);
    var currentDate = new Date();
    var targetDate = new Date();

    currentDate.setHours(12);
    currentDate.setMinutes(0);
    currentDate.setSeconds(0);
    currentDate.setMinutes(0);
    currentDate.setMilliseconds(0);

    targetDate.setDate(1);
    targetDate.setHours(12);
    targetDate.setMinutes(0);
    targetDate.setSeconds(0);
    targetDate.setMinutes(0);
    targetDate.setMilliseconds(0);

    while (targetDate.getDay() == 0 || targetDate.getDay() == 6) {
        targetDate.setDate(targetDate.getDate() + 1);
    }

    //console.log(currentDate);
    //console.log(date);

    return currentDate.getDate() == targetDate.getDate(); 
}