mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 22:27:26 +01:00
Added nextDue field
This commit is contained in:
@@ -105,7 +105,7 @@ export function shouldDo (day, dailyTask, options = {}) {
|
||||
|
||||
let startDate = moment(dailyTask.startDate).zone(o.timezoneOffset).startOf('day');
|
||||
|
||||
if (startDate > startOfDayWithCDSTime.startOf('day')) {
|
||||
if (startDate > startOfDayWithCDSTime.startOf('day') && !options.nextDue) {
|
||||
return false; // Daily starts in the future
|
||||
}
|
||||
|
||||
@@ -121,6 +121,9 @@ export function shouldDo (day, dailyTask, options = {}) {
|
||||
if (!dailyTask.everyX) return false; // error condition
|
||||
let schedule = moment(startDate).recur()
|
||||
.every(dailyTask.everyX).days();
|
||||
|
||||
if (options.nextDue) return schedule.next(3, 'L');
|
||||
|
||||
return schedule.matches(startOfDayWithCDSTime);
|
||||
} else if (dailyTask.frequency === 'weekly') {
|
||||
let schedule = moment(startDate).recur();
|
||||
@@ -131,6 +134,8 @@ export function shouldDo (day, dailyTask, options = {}) {
|
||||
|
||||
schedule = schedule.every(daysOfTheWeek).daysOfWeek();
|
||||
|
||||
if (options.nextDue) return schedule.next(3, 'L');
|
||||
|
||||
return schedule.matches(startOfDayWithCDSTime);
|
||||
} else if (dailyTask.frequency === 'monthly') {
|
||||
let schedule = moment(startDate).recur();
|
||||
@@ -145,12 +150,16 @@ export function shouldDo (day, dailyTask, options = {}) {
|
||||
schedule = schedule.every(dailyTask.daysOfMonth).daysOfMonth();
|
||||
}
|
||||
|
||||
if (options.nextDue) return schedule.next(3, 'L');
|
||||
|
||||
return schedule.matches(startOfDayWithCDSTime) && matchEveryX;
|
||||
} else if (dailyTask.frequency === 'yearly') {
|
||||
let schedule = moment(startDate).recur();
|
||||
|
||||
schedule = schedule.every(dailyTask.everyX).years();
|
||||
|
||||
if (options.nextDue) return schedule.next(3, 'L');
|
||||
|
||||
return schedule.matches(startOfDayWithCDSTime);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user