mirror of
https://github.com/woodchen-ink/certimate.git
synced 2025-07-18 17:31:55 +08:00
resolve build error
This commit is contained in:
parent
4475ed0dea
commit
44a6190e17
@ -1,8 +1,8 @@
|
|||||||
import { parseExpression } from "cron-parser";
|
import { CronExpressionParser } from "cron-parser";
|
||||||
|
|
||||||
export const validCronExpression = (expr: string): boolean => {
|
export const validCronExpression = (expr: string): boolean => {
|
||||||
try {
|
try {
|
||||||
parseExpression(expr);
|
CronExpressionParser.parse(expr);
|
||||||
|
|
||||||
if (expr.trim().split(" ").length !== 5) return false; // pocketbase 后端仅支持五段式的表达式
|
if (expr.trim().split(" ").length !== 5) return false; // pocketbase 后端仅支持五段式的表达式
|
||||||
return true;
|
return true;
|
||||||
@ -15,7 +15,7 @@ export const getNextCronExecutions = (expr: string, times = 1): Date[] => {
|
|||||||
if (!validCronExpression(expr)) return [];
|
if (!validCronExpression(expr)) return [];
|
||||||
|
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const cron = parseExpression(expr, { currentDate: now });
|
const cron = CronExpressionParser.parse(expr, { currentDate: now });
|
||||||
|
|
||||||
return cron.iterate(times).map((date) => date.toDate());
|
return cron.take(times).map((date) => date.toDate());
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user