feat: rrule format for x days repeat

This commit is contained in:
2026-07-20 13:41:47 +02:00
parent ca18d3b9e2
commit 40a8d02cd7
11 changed files with 317 additions and 168 deletions
+2 -18
View File
@@ -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 {