Skip to content

rhdeck/interval-manager

Repository files navigation

Manage Complex Time Intervals

interval-manager

Usage

npx @raydeck/interval-manager [options]

Get the next scheduled time based on the provided interval

Options

  • --hour <hour...> Set hour on which this should fire
  • --minute <minute...> Set minute on which this should fire
  • --second <second...> Set second on which this should file
  • --timezone <timezone> Timezone for this (default: America/Chicago)
  • --reference-date <isoDate> ISO-8601 representation of the reference (default: 2021-04-05T21:51:49.410Z)
  • --starting-date <isoDate> ISO-8601 representation of the date the interval had started (default: 2021-04-05T21:51:49.410Z)
  • --ending-date <isoDate> ISO-8601 representation of the date the interval had ended (default: 2021-04-05T21:51:49.410Z)
  • --dayOfMonth <daynumber...> Day of the month to run 1-31 (note that not all months have >28 days)
  • --dayOfWeek <dayofweek...> Day of the week to run, either a number from 0-6 one of sunday, monday, tuesday, wednesday, thursday, friday, saturday
  • --monthOfYear <month...> Month of the year to run in, either a number from 1-12 one of january, february, march, april, may, june, july, august, september, october, november, december
  • --orderInMonth <weekNumber...> Ordinal of the day of week within month to run, e.g. 2 and setting day of week to friday is second friday of the month
  • --dayOfYear <dayNumber...> Ordinal day of the year e.g. on ther 120th day of the year is 120
  • --weekInterval <weeks> Number of weeks between each event
  • --dayInterval <days> Number of days between each event
  • --maxDates <limit> Number of dates to return (default: 2)
  • --verbose Use human-readable version of the date as output (default is ISO-8601)

@raydeck/interval-manager - v2.0.0

@raydeck/interval-manager - v2.0.0

Table of contents

Interfaces

Variables

Functions

Variables

APRIL

Const APRIL: 4= 4

Defined in: index.ts:433


AUGUST

Const AUGUST: 8= 8

Defined in: index.ts:437


DAYINTERVALS

Const DAYINTERVALS: number[]

Valid day intervals

Defined in: index.ts:512


DAYSOFWEEK

Const DAYSOFWEEK: object

Type declaration:

Name Type
FRIDAY number
MONDAY number
SATURDAY number
SUNDAY number
THURSDAY number
TUESDAY number
WEDNESDAY number

Defined in: index.ts:477


DAYSOFYEAR

Const DAYSOFYEAR: number[]

Valid days of the year

Defined in: index.ts:508


DECEMBER

Const DECEMBER: 12= 12

Defined in: index.ts:441


FEBRUARY

Const FEBRUARY: 2= 2

Defined in: index.ts:431


FRIDAY

Const FRIDAY: 5= 5

Defined in: index.ts:428


HOURS

Const HOURS: number[]

Valid

Defined in: index.ts:502


JANUARY

Const JANUARY: 1= 1

Defined in: index.ts:430


JULY

Const JULY: 7= 7

Defined in: index.ts:436


JUNE

Const JUNE: 6= 6

Defined in: index.ts:435


LASTDAY

Const LASTDAY: -1= -1

Defined in: index.ts:442


MARCH

Const MARCH: 3= 3

Defined in: index.ts:432


MAY

Const MAY: 5= 5

Defined in: index.ts:434


MINUTES

Const MINUTES: number[]

Valid minutes

Defined in: index.ts:504


MONDAY

Const MONDAY: 1= 1

Defined in: index.ts:424


MONTHSOFYEAR

Const MONTHSOFYEAR: object

Type declaration:

Name Type
APRIL number
AUGUST number
DECEMBER number
FEBRUARY number
JANUARY number
JULY number
JUNE number
MARCH number
MAY number
NOVEMBER number
OCTOBER number
SEPTEMBER number

Defined in: index.ts:486


NOVEMBER

Const NOVEMBER: 11= 11

Defined in: index.ts:440


OCTOBER

Const OCTOBER: 10= 10

Defined in: index.ts:439


ORDERINMONTH

Const ORDERINMONTH: number[]

Defined in: index.ts:500


SATURDAY

Const SATURDAY: 6= 6

Defined in: index.ts:429


SECONDS

Const SECONDS: number[]

Valid seconds

Defined in: index.ts:506


SEPTEMBER

Const SEPTEMBER: 9= 9

Defined in: index.ts:438


SUNDAY

Const SUNDAY: 0= 0

Defined in: index.ts:423


THURSDAY

Const THURSDAY: 4= 4

Defined in: index.ts:427


TUESDAY

Const TUESDAY: 2= 2

Defined in: index.ts:425


WEDNESDAY

Const WEDNESDAY: 3= 3

Defined in: index.ts:426


WEEKINTERVALS

Const WEEKINTERVALS: number[]

Valid week intervals

Defined in: index.ts:516

Functions

getNextDate

getNextDate(schedule: IntervalSchedule, nowDate?: Date): Date

Get the next date/time after the specified reference date

Parameters:

Name Type Description
schedule IntervalSchedule IntervalSchedule that defines this interval pattern
nowDate Date Date the result must be after. Defaults to now

Returns: Date

Date with the next time this schedule should fire

Defined in: index.ts:10


isValidTimeZone

isValidTimeZone(tz: string): boolean

Determines whether a given string is a valid/known timezone identifier

Parameters:

Name Type Description
tz string Source string (e.g. America/New_York)

Returns: boolean

True if the string is a valid time zone, false if not

Defined in: index.ts:412


validateSchedule

validateSchedule(schedule: IntervalSchedule): void

Assert-style validator of whether a given IntervalSchedule contains valid values. Throws if not

Parameters:

Name Type Description
schedule IntervalSchedule IntervalSchedule to test

Returns: void

Defined in: index.ts:249

@raydeck/interval-manager - v2.0.0 / IntervalSchedule

Interface: IntervalSchedule

Interface for defining a schedule for delayed intervals

Table of contents

Properties

Properties

dayInterval

Optional dayInterval: number

Days to wait between runs, starting from the startsOn date. This can run multiple times per day if hour, minute or second are set with multiple values.Not compatible with weekInterval, monthsOfYear, daysOfYear

Defined in: index.ts:243


daysOfMonth

Optional daysOfMonth: number[]

Days of the month on which this should fire. Note that not all months have >28 days. Not compatible with dayInterval, weekInterval, daysOfYear

Defined in: index.ts:233


daysOfWeek

Optional daysOfWeek: number[]

Days of the week (specified as 0-6, where 0 is Sunday and 6 is Saturday). Not compatible with dayInterval, weekInterval, daysOfYear, daysOfMonth

Defined in: index.ts:235


daysOfYear

Optional daysOfYear: number[]

Days of the year on which this should fire. E.g. to run on the 88th day of the year, specify [88]. Note that not all months have >28 days. Not compatible with dayInterval, weekInterval, daysOfWeek

Defined in: index.ts:237


endingOn

Optional endingOn: Date

Ending date for this schedule

Defined in: index.ts:219


hours

hours: number[]

Hours (in local time) on which this schedule should fire

Defined in: index.ts:223


minutes

Optional minutes: number[]

Minutes on which this should fire (e.g. [0, 30] for on the hour and half-hour) (default [0])

Defined in: index.ts:227


monthsOfYear

Optional monthsOfYear: number[]

Months of the year on which this should fire. Not compatible with dayInterval, weekInterval, daysOfYear

Defined in: index.ts:231


orderInMonth

Optional orderInMonth: number[]

Order of the weekday to fire. For example, to run on the first friday, use {orderInMonth: [1], daysOfWeek:[5]}. Note that using this requires specifying daysOfWeek. Not compatibile with dayInterval, weekInterval, daysOfMonth, daysOfYear

Defined in: index.ts:241


seconds

Optional seconds: number[]

Seconds on which this should file (default [0])

Defined in: index.ts:229


startingOn

Optional startingOn: Date

Starting date for this schedule (matters for dayInterval and weekInterval)

Defined in: index.ts:215


timezone

timezone: string

Time zone to define local time rule (e.g. daylight savings)

Defined in: index.ts:211


weekInterval

Optional weekInterval: number

Weeks to wait between runs, starting from the startsOn date. This can run multiple times per day or on multiple weekdays based on daysOfWeek. Not compatible with dayInterval, monthsOfYear, daysOfYear

Defined in: index.ts:239

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published