Context API reference
The API property of the context object provides number of convenience methods for generating and manipulating values.
List of methods:
API.timestamp(shift: int, unit: str, base: str = Current_Time) -> str - returns a date in relation to now variable based on the shift and unit values. The function moves the returned value away from now by the shift number of specified units. Supported units: days, weeks, months, years. The value of now defaults to current time if not specified. An example of generating a date referring the same day last week: {context.API.timestamp(-1, 'weeks')}.
API.range(begin: str, end: str, unit: str = 'days') -> [str,str...] - returns list of temporal identifiers based on two dates. Supported units: days, weeks, months, years. Unspecified unit defaults to 'days'. The function returns a list of temporal identifiers based on the unit: 'YYYY-MM-DD' for days, 'YYYY-MM' for months, and 'YYYY-00-WW' for weeks. The result can be used with in expression filter in scenarios where more specific definition of filter is desired:
{context.API.range(context.API.timestamp(-30,'days'),context.API.timestamp(), 'days')}. This example generates list of dates between today and the date 30 days ago.
API.asdate(value: str, format: str = 'YYYY-MM-DD') -> str - interprets input value as datetime and returns string representation specified by format. Returns error if the input cannot be coerced to a valid datetime.
API.unixtime(base: str = Current_Time) -> int - return UNIX timestamp seconds. If base value can be coerced to datetime the return value corresponds to that time; default value
API.isoweek(shift: int = 0, unit: str = 'days', base: str = Current_Time) -> str - returns isoweek-formatted string (YYYY-00-WW) using the base, shift, and unit values. Base value default to current time.
API.look(path: str, row: lookable, default: any = None) -> any - returns a value from lookable according to specified JSON path or default value is the path is not found in lookable; lookable can be any data structure which support JSONPath lookup such as map or list.