feat: rrule format for x days repeat
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { SortType } from "@/enums";
|
||||
import type { RawTask, Task, TaskCreateData } from "@/types";
|
||||
import { CronExpressionParser } from "cron-parser";
|
||||
import { isOneTime } from "@/lib/cron";
|
||||
import { nextCronReset } from "@/lib/recurrence";
|
||||
|
||||
const TEMPORARY_ID = "tmp";
|
||||
|
||||
@@ -36,22 +35,7 @@ export function isTemporary(task: Task): boolean {
|
||||
}
|
||||
|
||||
export function taskNextReset(task: Task): Date | null {
|
||||
if (
|
||||
task.check_date === null ||
|
||||
task.reset_cron === null ||
|
||||
isOneTime(task.reset_cron)
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
const interval = CronExpressionParser.parse(task.reset_cron, {
|
||||
currentDate: task.check_date,
|
||||
hashSeed: task.id,
|
||||
});
|
||||
return interval.next().toDate();
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
return nextCronReset(task.check_date, task.reset_cron, task.id);
|
||||
}
|
||||
|
||||
export function taskCompleted(task: Task): boolean {
|
||||
|
||||
Reference in New Issue
Block a user