I am going to go ahead and attempt to answer a very ambiguous question. Given that, I am only going to post something that hopefully you can work with.
First off, this date stuff is "hard" so let's leverage StackOverflow to find stuff we can work with (it MIGHT be better to use a date library but let's build from others efforts - up vote them as useful!)
Some additional information on date comparisons: https://stackoverflow.com/a/493018/125981
// credit here: https://stackoverflow.com/a/1353711/125981
function isDate(d) {
if (Object.prototype.toString.call(d) === "[object Date]") {
// it is a date
if (isNaN(d.getTime())) { // d.valueOf() could also work
// date is not valid
return false;
} else {
// date is valid
return true;
}
} else {
// not a date
return false;
}
}
// return true if prior to yesterday, OR is today(exactly), is not tuesday, or is not thursday
function datefunc(date) {
var today = new Date();
if (isDate(date)) {
var yesterday = new Date(new Date().setDate(today.getDate() - 1));
var tomorrow = new Date(new Date().setDate(today.getDate() + 1));
console.log(today.getTime(), yesterday.getTime(), tomorrow.getTime());
if (date.getTime() < yesterday.getTime() || date.getTime() == today.getTime() || (date.getDay() != 2 && date.getDay() != 4)) {
return true;
}
}
return false;
}
// credit here: https://stackoverflow.com/a/27336600/125981
// if d is dow, return that else next dow
function currentOrNexDowDay(d, dow) {
d.setDate(d.getDate() + (dow + (7 - d.getDay())) % 7);
return d;
}
// credit here: https://stackoverflow.com/a/27336600/125981
// if cd is dow and not d, return that else next dow
function nextDowDay(d, dow) {
var cd = new Date(d);
cd.setDate(cd.getDate() + (dow + (7 - cd.getDay())) % 7);
if (d.getTime() === cd.getTime()) {
cd.setDate(cd.getDate() + 7);
}
return cd;
}
// a Tuesday
var checkDate = new Date("2018-02-13T17:30:29.569Z");
console.log(datefunc(checkDate));
// a Wednesday
checkDate = new Date("2018-02-14T17:30:29.569Z");
console.log(datefunc(checkDate));
// a Sunday
checkDate = new Date("2018-02-11T17:30:29.569Z");
console.log(datefunc(checkDate));
// Next Monday
var d = new Date();
d = currentOrNexDowDay(d, 1);
//d.setDate(d.getDate() + (8 - d.getDay()) % 7);
console.log(d);
console.log(datefunc(d));
// Next Tuesday
var dt = new Date();
dt = nextDowDay(dt, 2);
console.log(dt);
console.log(datefunc(dt));