Skip to main content

Class: Cron

@sapphire/cron.Cron

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

See

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

Constructors

constructor

new Cron(cron): Cron

Parameters

NameTypeDescription
cronstringThe cron pattern to use

Returns

Cron

Defined in

lib/Cron.ts:20

Properties

cron

cron: string

Defined in

lib/Cron.ts:9


days

days: number[]

Defined in

lib/Cron.ts:13


dows

dows: number[]

Defined in

lib/Cron.ts:15


hours

hours: number[]

Defined in

lib/Cron.ts:12


minutes

minutes: number[]

Defined in

lib/Cron.ts:11


months

months: number[]

Defined in

lib/Cron.ts:14


normalized

normalized: string

Defined in

lib/Cron.ts:10

Methods

next

next(outset?, origin?): Date

Get the next date that matches with the current pattern

Parameters

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

Returns

Date

Defined in

lib/Cron.ts:31


normalize

normalize(cron): string

Normalize the pattern

Parameters

NameTypeDescription
cronstringThe pattern to normalize

Returns

string

Defined in

lib/Cron.ts:54


parsePart

parsePart(cronPart, id): number[]

Parse the current part

Parameters

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

Returns

number[]

Defined in

lib/Cron.ts:100


parseString

parseString(cron): number[][]

Parse the pattern

Parameters

NameTypeDescription
cronstringThe pattern to parse

Returns

number[][]

Defined in

lib/Cron.ts:89