Helper functions
- Last Updated: June 21, 2023
- 2 minute read
- Corticon.js
- Documentation
A helper function is an object literal containing references to
decimal, date, and dateTime operators. It has the following syntax:
helper = { 'decimal': <all decimal operators>, 'dateTime': <all dateTime operators>, 'date': <all date operators> }
The list of operators is identical to list in the Corticon.js Studio operator tree.
The lists of helper functions are documented in the Studio's Rule Operator view. Exceptions are distinguished at the bottom of each list.
Decimal helper functions
The helper Decimal functions are as follows:
multiplydividenegatedexponentaddminusabsValfloorceilinglnloglogBaselessThanlessThanOrEqualequaldifferentgreaterThangreaterThanOrEqualminmaxrandomtoStringtoIntegerround
Exceptions:
isDecimalreturns a booleantrueif the object is a Decimal else returnsfalseconstructDecimalreturns a Decimal object. It accepts number or strings as parameter. For example,constructDecimal(10.5)orconstructDecimal("100000000000000000000000.56789")outputToJsonreturns a string representation suitable for inclusion in a JSON payload.
DateTime helper functions
The helper DateTime functions are as follows:
lessThanlessThanOrEqualequaldifferentgreaterThangreaterThanOrEqualaddYearsaddMonthsaddDaysaddHoursaddMinutesaddSecondsyearsBetweenmonthsBetweenweeksBetweendaysBetweenhoursBetweenminutesBetweensecondsBetweenyearmonthdayhourminsecnowdayOfWeekdayOfYeargetMillisecondsweekOfMonthweekOfYearafterDatebeforeDateisSameDateafterTimebeforeTimeisSameTime
Exceptions:
constructDateTimecreate a DateTime object. It accepts either a string which has to be an ISO-8601 representation of a DateTime or a long value which represents the time since epoch in milliseconds.isDateTimereturns a booleantrueif the object is a DateTime else returnsfalseoutputToJsonreturns a string representation in ISO-8601 format as UTC. The string is suitable for inclusion in a JSON payload.
Date helper functions
The helper Date functions are as follows:
lessThanlessThanOrEqualequaldifferentgreaterThangreaterThanOrEqualaddYearsaddMonthsaddDaysaddHoursaddMinutesaddSecondsyearsBetweenmonthsBetweenweeksBetweendaysBetweenhoursBetweenminutesBetweensecondsBetweenyearmonthdayhourminsecnowtoDatedayOfWeekdayOfYeargetMillisecondsweekOfMonthweekOfYearafterDatebeforeDateisSameDateafterTimebeforeTimeisSameTime
Exceptions:
constructDatecreate a Date object. It accepts either a string which has to be an ISO-8601 representation of a Date or a long value which represents the time since epoch in milliseconds.isDatereturns a booleantrueif the object is a Date else returnsfalseoutputToJsonreturns a string representation in ISO-8601 format as UTC. The string is suitable for inclusion in a JSON payload.