Adaptive Calendar
ai.calendar
The Adaptive Period which constitutes a period of time that can contain raw or aggregated data
Functions
Method | Parameters | Returns | Description |
---|---|---|---|
getNextPeriod( period [, options ] ) |
|
ai.calendar.period | Returns the next Period in the Adaptive Calendar from the period passed in the argument |
getPreviousPeriod( period [, options ] ) |
|
ai.calendar.period | Returns the previous Period in the Adaptive Calendar from the period passed in the argument |
getAvailablePeriodTypes( periodType ) |
|
Array<String> | Returns array of Stratum (Period type) codes supported by the calendar higher in the hierarchy than the stratum passed in (ex ['QuarterYear', 'HalfYear', 'Year'] ) |
getPeriodStartDateTime( period ) |
|
String | Returns the start date time for the period in ISO8601 date string format (ex '2015-06-15T12:00:00+10:00') |
getPeriodEndDateTime( period ) |
|
String | Returns the end date time for the period in ISO8601 date string format (ex '2015-06-15T12:00:00+10:00') |
convertToAdaptivePeriodStart ( start, end ) |
|
String | Returns the corresponding Adaptive Period start date in ISO8601 date string format (ex '2015-06-15T12:00:00+10:00') |
isWithinAdaptivePeriodRange ( start, end, periodFrom, periodEnd ) |
|
Boolean | Returns true if both the start date and end date given falls within the 2 the from period and to period. Returns false otherwise. (ex true/false) |
Example
function PreviewData(context) { var calendar = context.getCalendar(); var dataSource = context.getDataSource(); var periods = dataSource.getSetting("Periods").getValue(); // get period for next month in the adaptive calendar var nextMonth = calendar.getNextPeriod(periods.getFromPeriod()); }
function PreviewData(context) { var calendar = context.getCalendar(); var newDate = calendar.convertToAdaptivePeriodStart(ai.date.create('2016-02-01', 'America/Los_Angeles'), ai.date.create('2016-05-01', 'America/Los_Angeles')); // write the corresponding adaptive period start date to log. Assuming server in PST timezone the corresponding date would be '2016-04-01T00:00:00.0000000-07:00' ai.log.logInfo(newDate); }
ai.calendar.period
The Adaptive Period which constitutes a period of time that can contain raw or aggregated data
Functions
Method | Parameters | Returns | Description |
---|---|---|---|
getValue() | string | Returns the string value of the Period that child columns that can be used to pass to Calendar functions as arguments. |
Example
function PreviewData(context) { var dataSource = context.getDataSource(); var calendar = context.getCalendar(); var periods = dataSource.getSetting("Periods").getValue(); var period = calendar.nextPeriod(periods.getFromPeriod()); var nextPeriod = calendar.nextPeriod(period.getValue()); }