Cron
Constructors
Signature
declare function make(values: {
readonly and?: boolean;
readonly days: Iterable<number>;
readonly hours: Iterable<number>;
readonly minutes: Iterable<number>;
readonly months: Iterable<number>;
readonly seconds?: Iterable<number, any, any>;
readonly tz?: TimeZone;
readonly weekdays: Iterable<number>;
}): Cron;Parses a cron expression into a Cron instance.
Signature
declare function parse(cron: string, tz?: string | TimeZone): Either<Cron, ParseError>;unsafeParse
Parses a cron expression into a Cron instance.
Details
This function takes a cron expression as a string and attempts to parse it into a Cron instance. If the expression is valid, the resulting Cron instance will represent the schedule defined by the cron expression.
If the expression is invalid, the function throws a ParseError.
You can optionally provide a time zone (tz) to interpret the cron expression in a specific time zone. If no time zone is provided, the cron expression will use the default time zone.
Signature
declare function unsafeParse(cron: string, tz?: string | TimeZone): Cron;Guards
Checks if a given value is a Cron instance.
Signature
declare function isCron(u: unknown): u is Cron;isParseError
Returns true if the specified value is an ParseError, false otherwise.
Signature
declare function isParseError(u: unknown): u is ParseError;Instances
Equivalence
Signature
declare const Equivalence: equivalence.Equivalence<Cron>;Models
Signature
interface Cron extends Pipeable, Equal, Inspectable {
readonly [TypeId]: typeof TypeId;
readonly days: ReadonlySet<number>;
readonly hours: ReadonlySet<number>;
readonly minutes: ReadonlySet<number>;
readonly months: ReadonlySet<number>;
readonly seconds: ReadonlySet<number>;
readonly tz: Option<TimeZone>;
readonly weekdays: ReadonlySet<number>;
}ParseError
Represents a checked exception which occurs when decoding fails.
Signature
declare class ParseError extends YieldableError<this> & {
readonly _tag: "CronParseError";
} & Readonly<{
readonly input?: string;
readonly message: string;
}> {
constructor(args: {
readonly input?: string;
readonly message: string;
});
readonly [ParseErrorTypeId]: symbol;
}Other
Checks if a given Date falls within an active Cron time window.
Signature
declare function match(cron: Cron, date: Input): boolean;Returns the next run Date for the given Cron instance.
Uses the current time as a starting point if no value is provided for startFrom.
Signature
declare function next(cron: Cron, startFrom?: Input): Date;Returns the previous run Date for the given Cron instance.
Uses the current time as a starting point if no value is provided for startFrom.
Signature
declare function prev(cron: Cron, startFrom?: Input): Date;Returns an IterableIterator which yields the sequence of Dates that match the Cron instance.
Signature
declare function sequence(cron: Cron, startFrom?: Input): IterableIterator<Date>;sequenceReverse
Returns an IterableIterator which yields the sequence of Dates that match the Cron instance, in reverse direction.
Signature
declare function sequenceReverse(cron: Cron, startFrom?: Input): IterableIterator<Date>;Predicates
Symbol
ParseErrorTypeId
Signature
declare const ParseErrorTypeId: unique symbol;Signature
type TypeId = typeof TypeId;Symbols
ParseErrorTypeId type
Signature
type ParseErrorTypeId = typeof ParseErrorTypeId;Signature
declare const TypeId: unique symbol;
Creates a
Croninstance.