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