mirror of
https://github.com/certd/certd.git
synced 2025-11-25 09:10:11 +08:00
16 lines
413 B
TypeScript
16 lines
413 B
TypeScript
import parser from "cron-parser";
|
|
import dayjs from "dayjs";
|
|
|
|
export function getCronNextTimes(cron: string, count: number = 1) {
|
|
if (cron == null) {
|
|
return [];
|
|
}
|
|
const nextTimes = [];
|
|
const interval = parser.parseExpression(cron);
|
|
for (let i = 0; i < count; i++) {
|
|
const next = interval.next().getTime();
|
|
nextTimes.push(dayjs(next).format("YYYY-MM-DD HH:mm:ss"));
|
|
}
|
|
return nextTimes;
|
|
}
|