Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Interval

Class to describe ISO 8601 time intervals, including the repeating functionality.

The class is primarily backed by moment.js and contains the start, end, duration, and number of repetitions found in the ISO8601 string or overridden in the constructor. Typical usage of the class is to construct one with a ISO8601 string in the constructor.

Hierarchy

  • Interval

Index

Constructors

constructor

  • Parameters

    • Optional interval: string | Interval

      either ISO8601 string or an instance to copy

    • Optional repetitions: number

      the number of times to repeat, null for infinite

    Returns Interval

Properties

Private _duration

_duration: Duration

Private _end

_end: number

Private _first

_first: number

Private _infiniteSpan

_infiniteSpan: boolean

Private _last

_last: number

Private _recurs

_recurs: boolean

Private _repetitions

_repetitions: number

Private _start

_start: number

Accessors

duration

  • get duration(): Duration
  • The duration of a single repition of the interval

    Returns Duration

end

  • get end(): Moment
  • The end of all intervals, if this is a repeating interval then this is then end of the last repitition. Returns an invalid moment if there are infinite positive repetitions

    Returns Moment

first

  • get first(): number
  • Index of the first occurrence, Number.NEGATIVE_INFINITY if the interval is reverse repeating indefinitely

    Returns number

isInfinite

  • get isInfinite(): boolean
  • True if the schedule is infintely long

    Returns boolean

isInfiniteNegative

  • get isInfiniteNegative(): boolean
  • True if the schedule progresses infinitely in the negative

    Returns boolean

isInfinitePositive

  • get isInfinitePositive(): boolean
  • True if the schedule progresses infinitely in the positive

    Returns boolean

isRepeating

  • get isRepeating(): boolean
  • True if the schedule repeats (has more than one occurrence)

    Returns boolean

last

  • get last(): number
  • Index of the last occurrence, Number.POSITIVE_INFINITY if the interval is forward repeating indefinitely

    Returns number

repetitions

  • get repetitions(): number

start

  • get start(): Moment
  • The start of all intervals, if this is a repeating interval then this is the start of the first repitition. Returns an invalid moment if there are infinite negative repetitions

    Returns Moment

Methods

durationBetween

  • durationBetween(from: number, to: number): Duration
  • Parameters

    • from: number
    • to: number

    Returns Duration

indexAfter

  • indexAfter(after: string | number | Moment): number
  • Get the recurrence (the index of the occurrence) after the supplied time

    Parameters

    • after: string | number | Moment

      Moment or something that it parses (if a number, then in epoc ms)

    Returns number

indexBefore

  • indexBefore(before: string | number | Moment): number
  • Parameters

    • before: string | number | Moment

    Returns number

occurrence

  • occurrence(idx: number): Moment

occurrenceAfter

  • occurrenceAfter(after: string | number | Moment): Moment
  • Get the occurrence happening after the supplied date. Throws Error if there is no occurrence after the supplied date

    Parameters

    • after: string | number | Moment

    Returns Moment

slice

  • slice(from?: number, to?: number): Moment[]
  • Get a list of the occurrences for an interval, if no parameters are supplied then all occurrences are returned.

    Parameters

    • Optional from: number
    • Optional to: number

    Returns Moment[]

toISOString

  • toISOString(): string

toString

  • toString(): string

Static extents

Generated using TypeDoc