Skip to content

Time Pattern Functions

These functions are used for working with time patterns.

FunctionDescription
addPatternAdds a new time pattern to a project.
deletePatternDeletes a time pattern from a project.
getPatternIndexRetrieves the index of a time pattern given its ID name.
getPatternIdRetrieves the ID name of a time pattern given its index.
setPatternIdChanges the ID name of a time pattern given its index.
getPatternLengthRetrieves the number of time periods in a time pattern.
getPatternValueRetrieves a time pattern’s factor for a given time period.
setPatternValueSets a time pattern’s factor for a given time period.
getAveragePatternValueRetrieves the average of all pattern factors in a time pattern.
setPatternSets the pattern factors for a given time pattern.

Adds a new time pattern to a project.

addPattern(id: string): void;

Parameters

ParameterTypeDescription
id stringthe ID name of the pattern to add.

The new pattern contains a single time period whose factor is 1.0.


Deletes a time pattern from a project.

deletePattern(index: number): void;

Parameters

ParameterTypeDescription
indexnumberthe time pattern’s index (starting from 1).

Retrieves the index of a time pattern given its ID name.

getPatternIndex(id: string): number;

Parameters

ParameterTypeDescription
idstringthe ID name of a time pattern.

Returns

Number the time pattern’s index (starting from 1).


Retrieves the ID name of a time pattern given its index.

getPatternId(index: number): string;

Parameters

ParameterTypeDescription
indexnumbera time pattern index (starting from 1).

Returns

string the time pattern’s ID name.


Changes the ID name of a time pattern given its index.

setPatternId(index: number, id: string): void;

Parameters

ParameterTypeDescription
indexnumbera time pattern index (starting from 1).
idstringthe time pattern’s new ID name.

Retrieves the number of time periods in a time pattern.

getPatternLength(index: number): number;

Parameters

ParameterTypeDescription
indexnumbera time pattern index (starting from 1).

Returns

Number the number of time periods in the pattern.


Retrieves a time pattern’s factor for a given time period.

getPatternValue(index: number, period: number): number;

Parameters

ParameterTypeDescription
indexnumbera time pattern index (starting from 1).
periodnumbera time period in the pattern (starting from 1).

Returns

Number the pattern factor for the given time period.


Sets a time pattern’s factor for a given time period.

setPatternValue(index: number, period: number, value: number): void;

Parameters

ParameterTypeDescription
indexnumbera time pattern index (starting from 1).
periodnumbera time period in the pattern (starting from 1).
valuenumberthe new value of the pattern factor for the given time period.

Retrieves the average of all pattern factors in a time pattern.

getAveragePatternValue(index: number): number;

Parameters

ParameterTypeDescription
indexnumbera time pattern index (starting from 1).

Returns

Number The average of all of the time pattern’s factors.


Sets the pattern factors for a given time pattern.

setPattern(index: number, values: number[]): void;

Parameters

ParameterTypeDescription
indexnumbera time pattern index (starting from 1).
valuesnumber[]an array of new pattern factor values.

Use this function to redefine (and resize) a time pattern all at once; use setPatternValue to revise pattern factors one at a time.