Skip to main content

Class: Cron

Handles Cron strings and generates dates based on the cron string provided.

See

https://en.wikipedia.org/wiki/Cron

Constructors

new Cron()

new Cron(cron: string): Cron

Parameters

ParameterTypeDescription
cronstringThe cron pattern to use

Returns

Cron

Source

lib/Cron.ts:20

Properties

cron

cron: string

Source

lib/Cron.ts:9


days

days: number[]

Source

lib/Cron.ts:13


dows

dows: number[]

Source

lib/Cron.ts:15


hours

hours: number[]

Source

lib/Cron.ts:12


minutes

minutes: number[]

Source

lib/Cron.ts:11


months

months: number[]

Source

lib/Cron.ts:14


normalized

normalized: string

Source

lib/Cron.ts:10

Methods

next()

next(outset: Date, origin: boolean): Date

Get the next date that matches with the current pattern

Parameters

ParameterTypeDefault valueDescription
outsetDateundefinedThe Date instance to compare with
originbooleantrueWhether this next call is origin

Returns

Date

Source

lib/Cron.ts:31


normalize()

private static normalize(cron: string): string

Normalize the pattern

Parameters

ParameterTypeDescription
cronstringThe pattern to normalize

Returns

string

Source

lib/Cron.ts:54


parsePart()

private static parsePart(cronPart: string, id: number): number[]

Parse the current part

Parameters

ParameterTypeDescription
cronPartstringThe part of the pattern to parse
idnumberThe id that identifies the current part

Returns

number[]

Source

lib/Cron.ts:100


parseString()

private static parseString(cron: string): number[][]

Parse the pattern

Parameters

ParameterTypeDescription
cronstringThe pattern to parse

Returns

number[][]

Source

lib/Cron.ts:89