(cron: Cron, now?: DateTime.DateTime.Input): DateReturns the next scheduled date/time for the given Cron instance.
When to use
Use to find the next occurrence of a cron schedule after a specific date/time or after the current time.
Details
Searches for the next date and time when the cron schedule should trigger, starting after the specified date/time or after the current time when no date is provided.
Example (Finding the next occurrence)
import { Cron, Result } from "effect"
const cron = Result.getOrThrow(Cron.parse("0 0 4 8-14 * *"))
// Get next run after a specific date
const after = new Date("2021-01-01T00:00:00Z")
const nextRun = Cron.next(cron, after)
console.log(nextRun) // 2021-01-08T04:00:00.000Z
// Get next run from current time
const nextFromNow = Cron.next(cron)
console.log(nextFromNow) // Next occurrence from nowexport const const next: (
cron: Cron,
now?: DateTime.DateTime.Input
) => Date
Returns the next scheduled date/time for the given Cron instance.
When to use
Use to find the next occurrence of a cron schedule after a specific date/time
or after the current time.
Details
Searches for the next date and time when the cron schedule should trigger,
starting after the specified date/time or after the current time when no
date is provided.
Example (Finding the next occurrence)
import { Cron, Result } from "effect"
const cron = Result.getOrThrow(Cron.parse("0 0 4 8-14 * *"))
// Get next run after a specific date
const after = new Date("2021-01-01T00:00:00Z")
const nextRun = Cron.next(cron, after)
console.log(nextRun) // 2021-01-08T04:00:00.000Z
// Get next run from current time
const nextFromNow = Cron.next(cron)
console.log(nextFromNow) // Next occurrence from now
next = (cron: Cron(parameter) cron: {
tz: Option.Option<DateTime.TimeZone>;
seconds: ReadonlySet<number>;
minutes: ReadonlySet<number>;
hours: ReadonlySet<number>;
days: ReadonlySet<number>;
months: ReadonlySet<number>;
weekdays: ReadonlySet<number>;
and: boolean;
first: { readonly second: number; readonly minute: number; readonly hour: number; readonly day: number; readonly month: number; readonly weekday: number };
last: { readonly second: number; readonly minute: number; readonly hour: number; readonly day: number; readonly month: number; readonly weekday: number };
next: { readonly second: ReadonlyArray<number | undefined>; readonly minute: ReadonlyArray<number | undefined>; readonly hour: ReadonlyArray<number | undefined>; readonly day: ReadonlyArray<number | undefined>; readonly month: ReadonlyArray<numb…;
prev: { readonly second: ReadonlyArray<number | undefined>; readonly minute: ReadonlyArray<number | undefined>; readonly hour: ReadonlyArray<number | undefined>; readonly day: ReadonlyArray<number | undefined>; readonly month: ReadonlyArray<numb…;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
cron: Cron, now: DateTime.DateTime.Input | undefinednow?: import DateTimeDateTime.DateTime.type DateTime.Input = string | number | DateTime.DateTime | Partial<DateTime.DateTime.Parts> | DateTime.DateTime.Instant | DateTime.DateTime.InstantWithZone | DateInput accepted by DateTime.make, DateTime.makeUnsafe, and the zoned
constructors.
Details
Includes existing DateTime values, partial date parts, epoch-millisecond
objects, epoch milliseconds, JavaScript Date instances, and parseable date
strings.
Input): Date => {
return const stepCron: (
cron: Cron,
now: DateTime.DateTime.Input | undefined,
direction: "next" | "prev"
) => Date
stepCron(cron: Cron(parameter) cron: {
tz: Option.Option<DateTime.TimeZone>;
seconds: ReadonlySet<number>;
minutes: ReadonlySet<number>;
hours: ReadonlySet<number>;
days: ReadonlySet<number>;
months: ReadonlySet<number>;
weekdays: ReadonlySet<number>;
and: boolean;
first: { readonly second: number; readonly minute: number; readonly hour: number; readonly day: number; readonly month: number; readonly weekday: number };
last: { readonly second: number; readonly minute: number; readonly hour: number; readonly day: number; readonly month: number; readonly weekday: number };
next: { readonly second: ReadonlyArray<number | undefined>; readonly minute: ReadonlyArray<number | undefined>; readonly hour: ReadonlyArray<number | undefined>; readonly day: ReadonlyArray<number | undefined>; readonly month: ReadonlyArray<numb…;
prev: { readonly second: ReadonlyArray<number | undefined>; readonly minute: ReadonlyArray<number | undefined>; readonly hour: ReadonlyArray<number | undefined>; readonly day: ReadonlyArray<number | undefined>; readonly month: ReadonlyArray<numb…;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
toString: () => string;
toJSON: () => unknown;
}
cron, now: DateTime.DateTime.Input | undefinednow, "next")
}