UNPKG

@adaptabletools/adaptable

Version:

Powerful AG Grid extension which provides advanced, cutting-edge functionality to meet all DataGrid requirements

46 lines (45 loc) 1.66 kB
/** * Lightweight, dependency-free parser for standard 5-field cron expressions: * * minute hour day-of-month month day-of-week * * Each field supports: * - `*` — every value in the field range * - A single integer (e.g. `9`) * - A comma-separated list (e.g. `1,3,5`) * - A range (e.g. `1-5`) * - A step (e.g. `* /15`, `0-30/5`) * * For day-of-week, both `0` and `7` represent Sunday. * * This module exists to keep AdapTable free of the `cron-parser` package (which * transitively pulls in `luxon`). AdapTable only uses cron expressions in the * Scheduling system, and only ever needs to: * 1. validate a user-entered cron string, and * 2. compute the next fire time from "now". */ interface ParsedCron { minute: Set<number>; hour: Set<number>; dayOfMonth: Set<number>; month: Set<number>; dayOfWeek: Set<number>; /** True when the day-of-month field is `*` (i.e. unrestricted). */ dayOfMonthIsStar: boolean; /** True when the day-of-week field is `*` (i.e. unrestricted). */ dayOfWeekIsStar: boolean; } /** * Parses a 5-field cron expression. Throws when the expression is invalid. */ export declare function parseCronExpression(expression: string): ParsedCron; /** * Returns true if the given expression is a valid 5-field cron expression. */ export declare function isCronExpressionValid(expression: string): boolean; /** * Returns the next time the cron expression fires after `fromDate` (exclusive). * Returns null if no match is found within a 4-year horizon. */ export declare function getNextCronOccurrence(expression: string, fromDate?: Date): Date | null; export {};