in my app I have timed discounts (Example: 10:00 - 12:00), I want to display in a list these active discounts BUT for the discounts that will also be active tomorrow and the active deal time has already passed I want to have the word TOMORROW next to them, instead of TODAY.
When using moment to see if the active deal has already passed I can't get it to work properly...
let activeTableDiscount = null;
let activeTableDiscountText = 'TODAY';
let filteredTablesDiscountsToday = { /*same object*/ };
let filteredTablesDiscountTomorrow = {};
var start = moment('10:00', 'HH:mm');
var end = moment('12:00', 'HH:mm');
if (end.isBefore(start))
{
// If end is before start, then it must end must be tomorrow.
activeTableDiscount = filteredTablesDiscountsToday;
activeTableDiscountText = 'TODAY';
}
if (now.isBetween(start, end))
{
activeTableDiscount = filteredTablesDiscountsToday;
activeTableDiscountText = 'TODAY';
}
else {
if (start.isBefore(now)) {
// If start is before now and the range
// is not active, then start is tomorrow.
//start.add(1, "day");
activeTableDiscount = filteredTablesDiscountsTomorrow;
activeTableDiscountText = 'TOMORROW';
}
//activeTableDiscount = filteredTablesDiscountsTomorrow;
//activeTableDiscountText = 'Hoy';
}
Thanks in advance!