Skip to main content
Adaptive Insights
Knowledge and Support - Adaptive Insights

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 ] )
  • period: String
    Value of the period to get next period of time for
  • options: Object
    Object containing a type property 'number' and a value property as an int. Example: {type: 'number', value: 3}
ai.calendar.period Returns the next Period in the Adaptive Calendar from the period passed in the argument
getPreviousPeriod( period [, options ] )
  • period: String
    Value of the period to get previous period of time for
  • options: Object
    Object containing a type property 'number' and a value property as an int. Example: {type: 'number', value: 3}
ai.calendar.period Returns the previous Period in the Adaptive Calendar from the period passed in the argument
getAvailablePeriodTypes( periodType )
  • periodType: String
    Stratum code of one of the available Strata.
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 )
  • start: String
    ISO8601 formatted start date of the period to convert
  • end: String
    ISO8601 formatted end date of the period to convert
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 )
  • start: String
    ISO8601 formatted start date of the period to convert
  • end: String
    ISO8601 formatted end date of the period to convert
  • periodFrom: ai.calendar.period
    Period from which you want to compare
  • periodEnd: ai.calendar.period
    Period to which you want to compare
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());
} 
  • Was this article helpful?