Class: RepetitiveInterval

RepetitiveInterval

new RepetitiveInterval(startDate, endDate, intervalStartHour, intervalEndHour, nRepeats, repeatUnit)

A RepetitiveInterval is an advanced interval which can repeat and can be used to find a simple Interval that a time point falls in. Create a RepetitiveInterval with one of these forms: RepetitiveInterval() A RepetitiveInterval with one day duration, non-repeating.. RepetitiveInterval(startDate, endDate, intervalStartHour, intervalEndHour, nRepeats, repeatUnit). RepetitiveInterval(repetitiveInterval).
Parameters:
Name Type Description
startDate number The start date as milliseconds since Jan 1, 1970 UTC. startDate must be earlier than or same as endDate. Or if repeatUnit is RepetitiveInterval.RepeatUnit.NONE, then it must equal endDate.
endDate number The end date as milliseconds since Jan 1, 1970 UTC.
intervalStartHour number The start hour in the day, from 0 to 23. intervalStartHour must be less than intervalEndHour.
intervalEndHour number The end hour in the day from 1 to 24.
nRepeats number (optional) Repeat the interval nRepeats repetitions, every unit, until endDate. If ommitted, use 0.
repeatUnit number (optional) The unit of the repetition, from RepetitiveInterval.RepeatUnit. If ommitted, use NONE. If this is NONE or ommitted, then startDate must equal endDate.
Source:

Methods

(static) toDateOnlyMilliseconds_(timePoint) → {number}

Return a time point on the beginning of the date (without hours, minutes, etc.)
Parameters:
Name Type Description
timePoint number The time point as milliseconds since Jan 1, 1970 UTC.
Source:
Returns:
A time point as milliseconds since Jan 1, 1970 UTC.
Type
number

compare(other) → {number}

Compare this to the other RepetitiveInterval.
Parameters:
Name Type Description
other RepetitiveInterval The other RepetitiveInterval to compare to.
Source:
Returns:
-1 if this is less than the other, 1 if greater and 0 if equal.
Type
number

getEndDate() → {number}

Get the end date.
Source:
Returns:
The end date as milliseconds since Jan 1, 1970 UTC.
Type
number

getInterval(timePoint) → {object}

Get an interval that covers the time point. If there is no interval covering the time point, this returns false for isPositive and returns a negative interval.
Parameters:
Name Type Description
timePoint number The time point as milliseconds since Jan 1, 1970 UTC.
Source:
Returns:
An associative array with fields (isPositive, interval) where isPositive is true if the returned interval is positive or false if negative, and interval is the Interval covering the time point or a negative interval if not found.
Type
object

getIntervalEndHour() → {number}

Get the interval end hour.
Source:
Returns:
The interval end hour.
Type
number

getIntervalStartHour() → {number}

Get the interval start hour.
Source:
Returns:
The interval start hour.
Type
number

getNRepeats() → {number}

Get the number of repeats.
Source:
Returns:
The number of repeats.
Type
number

getRepeatUnit() → {number}

Get the repeat unit.
Source:
Returns:
The repeat unit, from RepetitiveInterval.RepeatUnit.
Type
number

getStartDate() → {number}

Get the start date.
Source:
Returns:
The start date as milliseconds since Jan 1, 1970 UTC.
Type
number

hasIntervalOnDate_(timePoint) → {boolean}

Check if the date of the time point is in any interval.
Parameters:
Name Type Description
timePoint number The time point as milliseconds since Jan 1, 1970 UTC.
Source:
Returns:
True if the date of the time point is in any interval.
Type
boolean