Skip to main content

Class: Cron

@sapphire/time-utilities.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)

Parameters

NameTypeDescription
cronstringThe cron pattern to use

Defined in

projects/utilities/packages/time-utilities/src/lib/Cron.ts:21

Properties

cron

โ€ข cron: string

Defined in

projects/utilities/packages/time-utilities/src/lib/Cron.ts:10


days

โ€ข days: number[]

Defined in

projects/utilities/packages/time-utilities/src/lib/Cron.ts:14


dows

โ€ข dows: number[]

Defined in

projects/utilities/packages/time-utilities/src/lib/Cron.ts:16


hours

โ€ข hours: number[]

Defined in

projects/utilities/packages/time-utilities/src/lib/Cron.ts:13


minutes

โ€ข minutes: number[]

Defined in

projects/utilities/packages/time-utilities/src/lib/Cron.ts:12


months

โ€ข months: number[]

Defined in

projects/utilities/packages/time-utilities/src/lib/Cron.ts:15


normalized

โ€ข normalized: string

Defined in

projects/utilities/packages/time-utilities/src/lib/Cron.ts:11

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

projects/utilities/packages/time-utilities/src/lib/Cron.ts:32


normalize

โ–ธ Static Private normalize(cron): string

Normalize the pattern

Parameters

NameTypeDescription
cronstringThe pattern to normalize

Returns

string

Defined in

projects/utilities/packages/time-utilities/src/lib/Cron.ts:55


parsePart

โ–ธ Static Private 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

projects/utilities/packages/time-utilities/src/lib/Cron.ts:101


parseString

โ–ธ Static Private parseString(cron): number[][]

Parse the pattern

Parameters

NameTypeDescription
cronstringThe pattern to parse

Returns

number[][]

Defined in

projects/utilities/packages/time-utilities/src/lib/Cron.ts:90