Embedded functions

Functions are called in calculated expressions. Every supported signature is listed for each function: argument types and the result type. Methods that are called on a value (for example, on an array or a dictionary) are described in Methods.

Type conversion

Function

Description

toBoolean(integer) boolean

Converts argument value to boolean type. Returns true if argument is 1, false if argument is 0, error if argument is other.

Argument: integer — integer value to convert.

toBoolean(string) boolean

Converts argument value to boolean type. Returns true if argument is "true", false if argument is "false", error if argument is other.

Argument: string — string value to convert.

toInteger(boolean) integer

Converts argument value to integer type. Returns 1 if argument is true, 0 if argument is false.

Argument: boolean — boolean value to convert.

toInteger(number) integer

Converts argument value to integer type. Rounds number value down. Returns integer value.

Argument: number — number value to convert.

toInteger(string) integer

Converts argument value to integer type. Returns integer value.

Argument: string — string value to convert.

toNumber(integer) number

Converts argument value to number type. Returns number value.

Argument: integer — integer value to convert.

toNumber(string) number

Converts argument value to number type. Returns number value.

Argument: string — string value to convert.

toColor(string) color

Converts argument value to color type. Returns color value.

Argument: string — string value to convert.

toUrl(string) url

Converts argument value to url type. Returns url value.

Argument: string — string value to convert.

getIntegerValue(string, integer) integer

Returns the value of a variable by its name. If the variable doesn't exist or has incorrect type, the default value would be returned.

Arguments:

  1. string — variable name.
  2. integer — fallback value.

getNumberValue(string, number) number

Returns the value of a variable by its name. If the variable doesn't exist or has incorrect type, the default value would be returned.

Arguments:

  1. string — variable name.
  2. number — fallback value.

getStringValue(string, string) string

Returns the value of a variable by its name. If the variable doesn't exist or has incorrect type, the default value would be returned.

Arguments:

  1. string — variable name.
  2. string — fallback value.

getUrlValue(string, url) url

Returns the value of a variable by its name. If the variable doesn't exist or has incorrect type, the default value would be returned.

Arguments:

  1. string — variable name.
  2. url — fallback value.

getUrlValue(string, string) url

Returns the value of a variable by its name. If the variable doesn't exist or has incorrect type, the default value would be returned.

Arguments:

  1. string — variable name.
  2. string — fallback value.

getColorValue(string, color) color

Returns the value of a variable by its name. If the variable doesn't exist or has incorrect type, the default value would be returned.

Arguments:

  1. string — variable name.
  2. color — fallback value.

getColorValue(string, string) color

Returns the value of a variable by its name. If the variable doesn't exist or has incorrect type, the default value would be returned.

Arguments:

  1. string — variable name.
  2. string — fallback value.

getBooleanValue(string, boolean) boolean

Returns the value of a variable by its name. If the variable doesn't exist or has incorrect type, the default value would be returned.

Arguments:

  1. string — variable name.
  2. boolean — fallback value.

getStoredIntegerValue(string, integer) integer

Returns the stored value by its name. If the value doesn't exist or has incorrect type, the default value would be returned.

Arguments:

  1. string — stored value name.
  2. integer — fallback value.

getStoredIntegerValue(string, string, integer) integer

Returns the stored value by its name. If the value doesn't exist in specified scope or has incorrect type, the default value would be returned.

Arguments:

  1. string — stored value name.
  2. string — storage scope: global — not bound to a specific card; card — bound to the current card. On Android the card is identified by DivDataTag, on iOS by the cardId parameter, on Web the scope value is passed to Store and the developer integrating DivKit must implement reading values for that scope.
  3. integer — fallback value.

getStoredNumberValue(string, number) number

Returns the stored value by its name. If the value doesn't exist or has incorrect type, the default value would be returned.

Arguments:

  1. string — stored value name.
  2. number — fallback value.

getStoredNumberValue(string, string, number) number

Returns the stored value by its name. If the value doesn't exist in specified scope or has incorrect type, the default value would be returned.

Arguments:

  1. string — stored value name.
  2. string — storage scope: global — not bound to a specific card; card — bound to the current card. On Android the card is identified by DivDataTag, on iOS by the cardId parameter, on Web the scope value is passed to Store and the developer integrating DivKit must implement reading values for that scope.
  3. number — fallback value.

getStoredStringValue(string, string) string

Returns the stored value by its name. If the value doesn't exist or has incorrect type, the default value would be returned.

Arguments:

  1. string — stored value name.
  2. string — fallback value.

getStoredStringValue(string, string, string) string

Returns the stored value by its name. If the value doesn't exist in specified scope or has incorrect type, the default value would be returned.

Arguments:

  1. string — stored value name.
  2. string — storage scope: global — not bound to a specific card; card — bound to the current card. On Android the card is identified by DivDataTag, on iOS by the cardId parameter, on Web the scope value is passed to Store and the developer integrating DivKit must implement reading values for that scope.
  3. string — fallback value.

getStoredUrlValue(string, url) url

Returns the stored value by its name. If the value doesn't exist or has incorrect type, the default value would be returned.

Arguments:

  1. string — stored value name.
  2. url — fallback value.

getStoredUrlValue(string, string, url) url

Returns the stored value by its name. If the value doesn't exist in specified scope or has incorrect type, the default value would be returned.

Arguments:

  1. string — stored value name.
  2. string — storage scope: global — not bound to a specific card; card — bound to the current card. On Android the card is identified by DivDataTag, on iOS by the cardId parameter, on Web the scope value is passed to Store and the developer integrating DivKit must implement reading values for that scope.
  3. url — fallback value.

getStoredUrlValue(string, string) url

Returns the stored value by its name. If the value doesn't exist or has incorrect type, the default value would be returned.

Arguments:

  1. string — stored value name.
  2. string — fallback value.

getStoredUrlValue(string, string, string) url

Returns the stored value by its name. If the value doesn't exist in specified scope or has incorrect type, the default value would be returned.

Arguments:

  1. string — stored value name.
  2. string — storage scope: global — not bound to a specific card; card — bound to the current card. On Android the card is identified by DivDataTag, on iOS by the cardId parameter, on Web the scope value is passed to Store and the developer integrating DivKit must implement reading values for that scope.
  3. string — fallback value.

getStoredColorValue(string, color) color

Returns the stored value by its name. If the value doesn't exist or has incorrect type, the default value would be returned.

Arguments:

  1. string — stored value name.
  2. color — fallback value.

getStoredColorValue(string, string, color) color

Returns the stored value by its name. If the value doesn't exist in specified scope or has incorrect type, the default value would be returned.

Arguments:

  1. string — stored value name.
  2. string — storage scope: global — not bound to a specific card; card — bound to the current card. On Android the card is identified by DivDataTag, on iOS by the cardId parameter, on Web the scope value is passed to Store and the developer integrating DivKit must implement reading values for that scope.
  3. color — fallback value.

getStoredColorValue(string, string) color

Returns the stored value by its name. If the value doesn't exist or has incorrect type, the default value would be returned.

Arguments:

  1. string — stored value name.
  2. string — fallback value.

getStoredColorValue(string, string, string) color

Returns the stored value by its name. If the value doesn't exist in specified scope or has incorrect type, the default value would be returned.

Arguments:

  1. string — stored value name.
  2. string — storage scope: global — not bound to a specific card; card — bound to the current card. On Android the card is identified by DivDataTag, on iOS by the cardId parameter, on Web the scope value is passed to Store and the developer integrating DivKit must implement reading values for that scope.
  3. string — fallback value.

getStoredBooleanValue(string, boolean) boolean

Returns the stored value by its name. If the value doesn't exist or has incorrect type, the default value would be returned.

Arguments:

  1. string — stored value name.
  2. boolean — fallback value.

getStoredBooleanValue(string, string, boolean) boolean

Returns the stored value by its name. If the value doesn't exist in specified scope or has incorrect type, the default value would be returned.

Arguments:

  1. string — stored value name.
  2. string — storage scope: global — not bound to a specific card; card — bound to the current card. On Android the card is identified by DivDataTag, on iOS by the cardId parameter, on Web the scope value is passed to Store and the developer integrating DivKit must implement reading values for that scope.
  3. boolean — fallback value.

getStoredArrayValue(string) array

Returns the stored value by its name. If the value doesn't exist or has incorrect type, the exception will be thrown.

Argument: string — stored value name.

getStoredArrayValue(string, string) array

Returns the stored value by its name. If the value doesn't exist in specified scope or has incorrect type, the exception will be thrown.

Arguments:

  1. string — stored value name.
  2. string — storage scope: global — not bound to a specific card; card — bound to the current card. On Android the card is identified by DivDataTag, on iOS by the cardId parameter, on Web the scope value is passed to Store and the developer integrating DivKit must implement reading values for that scope.

getStoredDictValue(string) dict

Returns the stored value by its name. If the value doesn't exist or has incorrect type, the exception will be thrown.

Argument: string — stored value name.

getStoredDictValue(string, string) dict

Returns the stored value by its name. If the value doesn't exist in specified scope or has incorrect type, the exception will be thrown.

Arguments:

  1. string — stored value name.
  2. string — storage scope: global — not bound to a specific card; card — bound to the current card. On Android the card is identified by DivDataTag, on iOS by the cardId parameter, on Web the scope value is passed to Store and the developer integrating DivKit must implement reading values for that scope.

Conversion to string

Function

Description

toString(array) string

Returns a string representation of given value.

Argument: array — array value.

toString(boolean) string

Returns a string representation of given value.

Argument: boolean — boolean value.

toString(color) string

Returns a string representation of given value.

Argument: color — color value.

toString(dict) string

Returns a string representation of given value.

Argument: dict — dictionary value.

toString(integer) string

Returns a string representation of given value.

Argument: integer — integer Value.

toString(number) string

Returns a string representation of given value.

Argument: number — number value.

toString(string) string

Returns a string representation of given value.

Argument: string — string value.

toString(url) string

Returns a string representation of given value.

Argument: url — url value.

Mathematical operations

Function

Description

div(integer, integer) integer

Calculates division between the first number and the second. Returns integer quotient of division.

Arguments:

  1. integer — divisible integer value.
  2. integer — divisor integer value.

div(number, number) number

Calculates division between the first number and the second. Returns number quotient of division.

Arguments:

  1. number — divisible number value.
  2. number — divisor number value.

mod(integer, integer) integer

Calculates remainder of division the first number and the second. Returns integer remainder of division.

Arguments:

  1. integer — divisible integer value.
  2. integer — divisor integer value.

mod(number, number) number

Calculates remainder of division the first number and the second. Returns number remainder of division.

Arguments:

  1. number — divisible number value.
  2. number — divisor number value.

mul(vararg integer) integer

Calculates multiplication between argument values. Returns integer result of multiplication.

Argument: integer (one or more values) — integer value to multiply.

mul(vararg number) number

Calculates multiplication between argument values. Returns number result of multiplication.

Argument: number (one or more values) — number value to multiply.

sub(vararg integer) integer

Calculates subtraction between argument values. Returns integer result of subtraction.

Argument: integer (one or more values) — integer value to subtract.

sub(vararg number) number

Calculates subtraction between argument values. Returns number result of subtraction.

Argument: number (one or more values) — number value to subtract.

sum(vararg integer) integer

Calculates sum between argument values. Returns integer result of sum.

Argument: integer (one or more values) — integer value to sum.

sum(vararg number) number

Calculates sum between argument values. Returns number result of sum.

Argument: number (one or more values) — number value to sum.

maxInteger() integer

Gets max value of integer type. Returns max integer value.

No arguments.

maxNumber() number

Gets max value of number type. Returns max number value.

No arguments.

minInteger() integer

Gets min value of integer type. Returns min integer value.

No arguments.

minNumber() number

Gets min value of number type. Returns min number value.

No arguments.

max(vararg integer) integer

Gets max value of argument values. Returns max integer value.

Argument: integer (one or more values) — integer value.

max(vararg number) number

Gets max value of argument values. Returns max number value.

Argument: number (one or more values) — number value.

min(vararg integer) integer

Gets min value of argument values. Returns min integer value.

Argument: integer (one or more values) — integer value.

min(vararg number) number

Gets min value of argument values. Returns min number value.

Argument: number (one or more values) — number value.

abs(integer) integer

Gets absolute value of argument. Returns integer value.

Argument: integer — integer value to get absolute.

abs(number) number

Gets absolute value of argument. Returns number value.

Argument: number — number value to get absolute.

signum(integer) integer

Gets sign value from argument. Returns -1 if value is negative, 0 if value is equal to 0, 1 if value is positive.

Argument: integer — integer value to get sign value.

signum(number) number

Gets sign value from argument. Returns -1.0 if value is negative, 0.0 if value is equal to 0, 1.0 if value is positive.

Argument: number — number value to get sign value.

round(number) number

Rounds argument value to the closest integer value. 1.49 -> 1.0, 1.5 -> 2.0. Returns number value.

Argument: number — number value to round.

floor(number) number

Rounds argument value down. 1.49 -> 1.0, 1.5 -> 1.0. Returns number value.

Argument: number — number value to round.

ceil(number) number

Rounds argument value up. 1.49 -> 2.0, 1.5 -> 2.0. Returns number value.

Argument: number — number value to round.

copySign(integer, integer) integer

Gets value of first argument with sign of the second argument. Returns integer value.

Arguments:

  1. integer — integer value to copy value from.
  2. integer — integer value to copy sign from.

copySign(number, number) number

Gets value of first argument with sign of the second argument. Returns number value.

Arguments:

  1. number — number value to copy value from.
  2. number — number value to copy sign from.

Trigonometric functions

Function

Description

pi() number

Returns value of the π: ratio of the circumference of a circle to its diameter

No arguments.

toRadians(number) number

Converts the argument value from degrees to radians

Argument: number — number value representing degrees.

toDegrees(number) number

Converts the argument value from radians to degrees

Argument: number — number value representing radians.

sin(number) number

Calculates the sine of the given angle in radians

Argument: number — angle in radians.

cos(number) number

Calculates the cosine of the given angle in radians

Argument: number — angle in radians.

tan(number) number

Calculates the tangent of the given angle in radians

Argument: number — angle in radians.

asin(number) number

Calculates the angle in radians of the given sine value

Argument: number — sine value.

acos(number) number

Calculates the angle in radians of the given cosine value

Argument: number — cosine value.

atan(number) number

Calculates the angle in radians for a given tangent value

Argument: number — tangent value.

atan2(number, number) number

Calculates the angle in radians for given values (y,x)

Arguments:

  1. number — Y coordinate of the point
  2. number — X coordinate of the point

Available platforms: Android, web.

cot(number) number

Calculates the cotangent of the given angle in radians

Argument: number — angle in radians.

String operations

Function

Description

len(string) integer

Gets the length of string argument. Returns integer value.

Argument: string — string value to get length of.

contains(string, string) boolean

Gets if second string argument contains in first string argument. Returns boolean value.

Arguments:

  1. string — string value to find substring.
  2. string — string value substring to find.

substring(string, integer, integer) string

Gets substring of first argument in range of last arguments. Returns string value.

Arguments:

  1. string — string value to get substring from.
  2. integer — integer value, left index of substring.
  3. integer — integer value, right index of substring.

replaceAll(string, string, string) string

Replaces all occurrences of the second argument in the first argument with the third argument. Returns string value of replaced string.

Arguments:

  1. string — string value, original string.
  2. string — string value, string to find.
  3. string — string value, string to replace.

index(string, string) integer

Gets first index of second argument in first argument. Returns integer value, index of occurrence or -1 if substring is not found.

Arguments:

  1. string — string value, original string.
  2. string — string value, string to find.

lastIndex(string, string) integer

Gets last index of second argument in first argument. Returns integer value, index of occurrence or -1 if substring is not found.

Arguments:

  1. string — string value, original string.
  2. string — string value, string to find.

encodeUri(string) string

Translates a string into application/x-www-form-urlencoded format using a specific encoding scheme. Returns string value, encoded string.

Argument: string — string value to translate.

decodeUri(string) string

Decodes a application/x-www-form-urlencoded string using a specific encoding scheme. Returns string value, decoded string.

Argument: string — string value to decode.

trim(string) string

Returns a string having leading and trailing whitespace removed.

Argument: string — string value to trim.

trimLeft(string) string

Returns a string having leading whitespace removed.

Argument: string — string value to trim.

trimRight(string) string

Returns a string having trailing whitespace removed.

Argument: string — string value to trim.

toUpperCase(string) string

Returns converted to upper case string.

Argument: string — string value to transform.

toLowerCase(string) string

Returns converted to lower case string.

Argument: string — string value to transform.

padStart(string, integer, string) string

Pads a string to a given string length, inserting at start

Arguments:

  1. string — string value to pad.
  2. integer — string length
  3. string — string character to pad with

padStart(integer, integer, string) string

Converts given integer to a string and pads it to a given string length, inserting at start

Arguments:

  1. integer — integer value to pad.
  2. integer — string length
  3. string — string character to pad with

padEnd(string, integer, string) string

Pads a string to a given string length, inserting at end

Arguments:

  1. string — string value to pad.
  2. integer — string length
  3. string — string character to pad with

padEnd(integer, integer, string) string

Converts given integer to a string and pads it to a given string length, inserting at end

Arguments:

  1. integer — integer value to pad.
  2. integer — string length
  3. string — string character to pad with

testRegex(string, string) boolean

Checks whether the string matches the regular expression.

Arguments:

  1. string — A string to test.
  2. string — regex string.

encodeRegex(string) string

Encodes a string for safe use in regular expressions.

Argument: string — A string to encode.

Available platforms: Android, web.

Color operations

Function

Description

getColorAlpha(string) number

Gets alpha value of argument color. Returns number value in range 0.0 to 1.0 of alpha value of color.

Argument: string — string value of color in hex format.

getColorAlpha(color) number

Gets alpha value of argument color. Returns number value in range 0.0 to 1.0 of alpha value of color.

Argument: color — color

getColorRed(string) number

Gets red value of argument color. Returns number value in range 0.0 to 1.0 of red value of color.

Argument: string — string value of color in hex format.

getColorRed(color) number

Gets red value of argument color. Returns number value in range 0.0 to 1.0 of red value of color.

Argument: color — color

getColorGreen(string) number

Gets green value of argument color. Returns number value in range 0.0 to 1.0 of green value of color.

Argument: string — string value of color in hex format.

getColorGreen(color) number

Gets green value of argument color. Returns number value in range 0.0 to 1.0 of green value of color.

Argument: color — color.

getColorBlue(string) number

Gets blue value of argument color. Returns number value in range 0.0 to 1.0 of blue value of color.

Argument: string — string value of color in hex format.

getColorBlue(color) number

Gets blue value of argument color. Returns number value in range 0.0 to 1.0 of blue value of color.

Argument: color — color.

setColorAlpha(string, number) color

Sets alpha value of argument color. Returns string value of color in hex format '#FFAABBCC'.

Arguments:

  1. string — string value of color in hex format.
  2. number — number value of alpha in range 0.0 to 1.0.

setColorAlpha(color, number) color

Sets alpha value of argument color. Returns color.

Arguments:

  1. color — color.
  2. number — number value of alpha in range 0.0 to 1.0.

setColorRed(string, number) color

Sets red value of argument color. Returns string value of color in hex format '#FFAABBCC'.

Arguments:

  1. string — string value of color in hex format.
  2. number — number value of red in range 0.0 to 1.0.

setColorRed(color, number) color

Sets red value of argument color. Returns color.

Arguments:

  1. color — color.
  2. number — number value of red in range 0.0 to 1.0.

setColorGreen(string, number) color

Sets green value of argument color. Returns string value of color in hex format '#FFAABBCC'.

Arguments:

  1. string — string value of color in hex format.
  2. number — number value of green in range 0.0 to 1.0.

setColorGreen(color, number) color

Sets green value of argument color. Returns Color.

Arguments:

  1. color — color.
  2. number — number value of green in range 0.0 to 1.0.

setColorBlue(string, number) color

Sets blue value of argument color. Returns string value of color in hex format '#FFAABBCC'.

Arguments:

  1. string — string value of color in hex format.
  2. number — number value of blue in range 0.0 to 1.0.

setColorBlue(color, number) color

Sets blue value of argument color. Returns Color.

Arguments:

  1. color — color.
  2. number — number value of blue in range 0.0 to 1.0.

argb(number, number, number, number) color

Creates color from values of alpha, red, green, blue values. Returns string value of color in hex format '#FFAABBCC'.

Arguments:

  1. number — number value of alpha in range 0.0 to 1.0.
  2. number — number value of red in range 0.0 to 1.0.
  3. number — number value of green in range 0.0 to 1.0.
  4. number — number value of blue in range 0.0 to 1.0.

alphaBlend(color, color) color

Blends two colors by alpha channel. Returns color.

Arguments:

  1. color — background color.
  2. color — foreground color.

rgb(number, number, number) color

Creates color from values of red, green, blue values. Sets alpha value as 1.0. Returns color value of color in hex format '#FFAABBCC'.

Arguments:

  1. number — number value of red in range 0.0 to 1.0.
  2. number — number value of green in range 0.0 to 1.0.
  3. number — number value of blue in range 0.0 to 1.0.

Date and time operations

Function

Description

parseUnixTime(integer) datetime

Creates datetime from integer value of unix time. Returns datetime value.

Argument: integer — time in UTC seconds from the epoch.

parseUnixTimeAsLocal(integer) datetime

Creates datetime in local timezone from integer value of unix time. Returns datetime value.

Argument: integer — time in local time zone seconds from the epoch.

nowLocal() datetime

Creates datetime from time of now. Returns datetime value.

No arguments.

addMillis(datetime, integer) datetime

Adds milliseconds to original date. Returns datetime with added time in milliseconds.

Arguments:

  1. datetime — datetime value, date to add milliseconds.
  2. integer — integer value, count of milliseconds to add.

setYear(datetime, integer) datetime

Sets year number to original date. Returns datetime with year set.

Arguments:

  1. datetime — datetime value, date to set year.
  2. integer — integer value, year to set to date.

setMonth(datetime, integer) datetime

Sets month number to original date. Returns datetime with month set.

Arguments:

  1. datetime — datetime value, date to set month.
  2. integer — integer value, month to set to date. Expected values from 1 to 12.

setDay(datetime, integer) datetime

Sets day of month number to original date. Returns datetime with day of month set.

Arguments:

  1. datetime — datetime value, date to set day of month.
  2. integer — integer value, day of month to set to date.

setHours(datetime, integer) datetime

Sets hours number to original date. Returns datetime with hours set.

Arguments:

  1. datetime — datetime value, date to set hours.
  2. integer — integer value, hours to set to date.

setMinutes(datetime, integer) datetime

Sets minutes number to original date. Returns datetime with minutes set.

Arguments:

  1. datetime — datetime value, date to set minutes.
  2. integer — integer value, minutes to set to date.

setSeconds(datetime, integer) datetime

Sets seconds number to original date. Returns datetime with seconds set.

Arguments:

  1. datetime — datetime value, date to set seconds.
  2. integer — integer value, seconds to set to date.

setMillis(datetime, integer) datetime

Sets milliseconds number to original date. Returns datetime with milliseconds set.

Arguments:

  1. datetime — datetime value, date to set milliseconds.
  2. integer — integer value, milliseconds to set to date.

getYear(datetime) integer

Returns year number of original date.

Argument: datetime — datetime value, date to get year.

getMonth(datetime) integer

Returns month number of original date.

Argument: datetime — datetime value, date to get month.

getDay(datetime) integer

Returns day of month of original date.

Argument: datetime — datetime value, date to get day of month.

getDayOfWeek(datetime) integer

Returns day of week of original date, where Sunday is 7.

Argument: datetime — datetime value, date to get day of week.

getHours(datetime) integer

Returns hours number of original date.

Argument: datetime — datetime value, date to get hours.

getMinutes(datetime) integer

Returns minutes number of original date.

Argument: datetime — datetime value, date to get minutes.

getSeconds(datetime) integer

Returns seconds number of original date.

Argument: datetime — datetime value, date to get seconds.

getMillis(datetime) integer

Returns milliseconds number of original date.

Argument: datetime — datetime value, date to get milliseconds.

getTimestamp(datetime) integer

Returns the datetime value as timestamp in milliseconds.

Argument: datetime — datetime value to convert to timestamp in milliseconds.

formatDateAsLocal(datetime, string) string

Formatting dates in a local timezone in users locale. Used default locale. Look https://en.wikipedia.org/wiki/ISO_8601 for more. Z for timezones not supported.

Arguments:

  1. datetime — datetime value, date to get milliseconds.
  2. string — date and time formats are specified by date and time pattern strings.

formatDateAsUTC(datetime, string) string

Formatting dates in a UTC timezone in users locale. Used default locale. Look https://en.wikipedia.org/wiki/ISO_8601 for more. Z for timezones not supported.

Arguments:

  1. datetime — datetime value, date to get milliseconds.
  2. string — date and time formats are specified by date and time pattern strings.

formatDateAsLocalWithLocale(datetime, string, string) string

Formatting dates in a local timezone with localization. Look https://en.wikipedia.org/wiki/ISO_8601 for more. Z for timezones not supported.

Arguments:

  1. datetime — datetime value, date to get milliseconds.
  2. string — date and time formats are specified by date and time pattern strings.
  3. string — language for specified date and time pattern strings.

formatDateAsUTCWithLocale(datetime, string, string) string

Formatting dates in a UTC timezone with localization. Look https://en.wikipedia.org/wiki/ISO_8601 for more. Z for timezones not supported.

Arguments:

  1. datetime — datetime value, date to get milliseconds.
  2. string — date and time formats are specified by date and time pattern strings.
  3. string — language for specified date and time pattern strings.

Time interval operations

Function

Description

getIntervalSeconds(integer) integer

Gets the seconds component of the duration. Expressed as a value between 0 and 59.

Argument: integer — milliseconds count

getIntervalTotalSeconds(integer) integer

Gets the number of seconds in duration.

Argument: integer — milliseconds count

getIntervalMinutes(integer) integer

Gets the minutes component of the duration. Expressed as a value between 0 and 59.

Argument: integer — milliseconds count

getIntervalTotalMinutes(integer) integer

Gets the number of minutes in duration.

Argument: integer — milliseconds count

getIntervalHours(integer) integer

Gets the hours component of the duration. Expressed as a value between 0 and 23.

Argument: integer — milliseconds count

getIntervalTotalHours(integer) integer

Gets the number of hours in duration.

Argument: integer — milliseconds count

getIntervalTotalDays(integer) integer

Gets the number of days in duration.

Argument: integer — milliseconds count

getIntervalTotalWeeks(integer) integer

Gets the number of weeks in duration.

Argument: integer — milliseconds count

Array operations

Function

Description

getArrayString(array, integer) string

Returns a string value from array.

Arguments:

  1. array — array.
  2. integer — index at array.

getArrayNumber(array, integer) number

Returns a number value from array.

Arguments:

  1. array — array.
  2. integer — index at array.

getArrayInteger(array, integer) integer

Returns an integer value from array.

Arguments:

  1. array — array.
  2. integer — index at array.

getArrayBoolean(array, integer) boolean

Returns a boolean property from array.

Arguments:

  1. array — array.
  2. integer — index at array.

getArrayColor(array, integer) color

Returns a color property from array.

Arguments:

  1. array — array.
  2. integer — index at array.

getArrayOptString(array, integer, string) string

Returns an optional string property from array.

Arguments:

  1. array — array.
  2. integer — index at array.
  3. string — fallback value if value by index not exists or it's is not a string.

getArrayOptNumber(array, integer, number) number

Returns an optional number property from array.

Arguments:

  1. array — array.
  2. integer — index at array.
  3. number — fallback value if value by index not exists or it's is not a number.

getArrayOptInteger(array, integer, integer) integer

Returns an optional integer property from array.

Arguments:

  1. array — array.
  2. integer — index at array.
  3. integer — fallback value if property does not exist or a property value is not an integer.

getArrayOptBoolean(array, integer, boolean) boolean

Returns an optional boolean value from array.

Arguments:

  1. array — array.
  2. integer — index at array.
  3. boolean — fallback value if value by index not exists or it's is not a boolean.

getArrayOptColor(array, integer, color) color

Returns an optional color value from array.

Arguments:

  1. array — array.
  2. integer — index at array.
  3. color — fallback value if value by index not exists or it's is not a color.

getArrayOptColor(array, integer, string) color

Returns an optional color value from array.

Arguments:

  1. array — array.
  2. integer — index at array.
  3. string — fallback value if value by index not exists or it's is not a color.

getArrayUrl(array, integer) url

Returns an url value from array.

Arguments:

  1. array — array.
  2. integer — index at array.

getArrayOptUrl(array, integer, url) url

Returns an optional url value from array.

Arguments:

  1. array — array.
  2. integer — index at array.
  3. url — fallback value if value by index not exists or it's is not a url.

getArrayOptUrl(array, integer, string) url

Returns an optional url value from array.

Arguments:

  1. array — array.
  2. integer — index at array.
  3. string — fallback value if value by index not exists or it's is not a url.

getStringFromArray(array, integer) string

Returns a string value from array.

Arguments:

  1. array — array.
  2. integer — index at array.

getNumberFromArray(array, integer) number

Returns a number value from array.

Arguments:

  1. array — array.
  2. integer — index at array.

getIntegerFromArray(array, integer) integer

Returns an integer value from array.

Arguments:

  1. array — array.
  2. integer — index at array.

getBooleanFromArray(array, integer) boolean

Returns a boolean property from array.

Arguments:

  1. array — array.
  2. integer — index at array.

getColorFromArray(array, integer) color

Returns a color property from array.

Arguments:

  1. array — array.
  2. integer — index at array.

getOptStringFromArray(array, integer, string) string

Returns an optional string property from array.

Arguments:

  1. array — array.
  2. integer — index at array.
  3. string — fallback value if value by index not exists or it's is not a string.

getOptNumberFromArray(array, integer, number) number

Returns an optional number property from array.

Arguments:

  1. array — array.
  2. integer — index at array.
  3. number — fallback value if value by index not exists or it's is not a number.

getOptIntegerFromArray(array, integer, integer) integer

Returns an optional integer property from array.

Arguments:

  1. array — array.
  2. integer — index at array.
  3. integer — fallback value if property does not exist or a property value is not an integer.

getOptBooleanFromArray(array, integer, boolean) boolean

Returns an optional boolean value from array.

Arguments:

  1. array — array.
  2. integer — index at array.
  3. boolean — fallback value if value by index not exists or it's is not a boolean.

getOptColorFromArray(array, integer, color) color

Returns an optional color value from array.

Arguments:

  1. array — array.
  2. integer — index at array.
  3. color — fallback value if value by index not exists or it's is not a color.

getOptColorFromArray(array, integer, string) color

Returns an optional color value from array.

Arguments:

  1. array — array.
  2. integer — index at array.
  3. string — fallback value if value by index not exists or it's is not a color.

getUrlFromArray(array, integer) url

Returns an url value from array.

Arguments:

  1. array — array.
  2. integer — index at array.

getOptUrlFromArray(array, integer, url) url

Returns an optional url value from array.

Arguments:

  1. array — array.
  2. integer — index at array.
  3. url — fallback value if value by index not exists or it's is not a url.

getOptUrlFromArray(array, integer, string) url

Returns an optional url value from array.

Arguments:

  1. array — array.
  2. integer — index at array.
  3. string — fallback value if value by index not exists or it's is not a url.

getArrayFromArray(array, integer) array

Returns an array value from array

Arguments:

  1. array — array.
  2. integer — index at array.

getOptArrayFromArray(array, integer) array

Returns an array value from array if exist or empty array otherwise

Arguments:

  1. array — array.
  2. integer — index at array.

getDictFromArray(array, integer) dict

Returns an dict value from array

Arguments:

  1. array — array.
  2. integer — index at array.

getOptDictFromArray(array, integer) dict

Returns an dict value from array if exist or empty dict otherwise

Arguments:

  1. array — array.
  2. integer — index at array.

len(array) integer

Gets the length of array. Returns integer value.

Argument: array — array value to get length of.

Dictionary operations

Function

Description

getDictString(dict, vararg string) string

Returns a string value from dictionary.

Arguments:

  1. dict — dictionary.
  2. string (one or more values) — path in dictionary.

getDictNumber(dict, vararg string) number

Returns a number value from dictionary.

Arguments:

  1. dict — dictionary.
  2. string (one or more values) — path in dictionary.

getDictInteger(dict, vararg string) integer

Returns an integer value from dictionary.

Arguments:

  1. dict — dictionary.
  2. string (one or more values) — path in dictionary.

getDictBoolean(dict, vararg string) boolean

Returns a boolean property from dictionary.

Arguments:

  1. dict — dictionary.
  2. string (one or more values) — path in dictionary.

getDictColor(dict, vararg string) color

Returns a color property from dictionary.

Arguments:

  1. dict — dictionary.
  2. string (one or more values) — path in dictionary.

getDictUrl(dict, vararg string) url

Returns an url property from dictionary.

Arguments:

  1. dict — dictionary.
  2. string (one or more values) — path in dictionary.

getDictOptString(string, dict, vararg string) string

Returns an optional string property from dictionary.

Arguments:

  1. string — fallback value if property does not exist or a property value is not a string.
  2. dict — dictionary.
  3. string (one or more values) — path in dictionary.

getDictOptNumber(number, dict, vararg string) number

Returns an optional number property from dictionary.

Arguments:

  1. number — fallback value if property does not exist or a property value is not a number.
  2. dict — dictionary.
  3. string (one or more values) — path in dictionary.

getDictOptInteger(integer, dict, vararg string) integer

Returns an optional integer property from dictionary.

Arguments:

  1. integer — fallback value if property does not exist or a property value is not an integer.
  2. dict — dictionary.
  3. string (one or more values) — path in dictionary.

getDictOptBoolean(boolean, dict, vararg string) boolean

Returns an optional boolean property from dictionary.

Arguments:

  1. boolean — fallback value if property does not exist or a property value is not a boolean.
  2. dict — dictionary.
  3. string (one or more values) — path in dictionary.

getDictOptColor(color, dict, vararg string) color

Returns an optional color property from dictionary.

Arguments:

  1. color — fallback value if property does not exist or a property value is not a color.
  2. dict — dictionary.
  3. string (one or more values) — path in dictionary.

getDictOptColor(string, dict, vararg string) color

Returns an optional color property from dictionary.

Arguments:

  1. string — fallback value if property does not exist or a property value is not a color.
  2. dict — dictionary.
  3. string (one or more values) — path in dictionary.

getDictOptUrl(url, dict, vararg string) url

Returns an optional url property from dictionary.

Arguments:

  1. url — fallback value if property does not exist or a property value is not an url.
  2. dict — dictionary.
  3. string (one or more values) — path in dictionary.

getDictOptUrl(string, dict, vararg string) url

Returns an optional url property from dictionary.

Arguments:

  1. string — fallback value if property does not exist or a property value is not an url.
  2. dict — dictionary.
  3. string (one or more values) — path in dictionary.

getStringFromDict(dict, vararg string) string

Returns a string value from dictionary.

Arguments:

  1. dict — dictionary.
  2. string (one or more values) — path in dictionary.

getNumberFromDict(dict, vararg string) number

Returns a number value from dictionary.

Arguments:

  1. dict — dictionary.
  2. string (one or more values) — path in dictionary.

getIntegerFromDict(dict, vararg string) integer

Returns an integer value from dictionary.

Arguments:

  1. dict — dictionary.
  2. string (one or more values) — path in dictionary.

getBooleanFromDict(dict, vararg string) boolean

Returns a boolean property from dictionary.

Arguments:

  1. dict — dictionary.
  2. string (one or more values) — path in dictionary.

getColorFromDict(dict, vararg string) color

Returns a color property from dictionary.

Arguments:

  1. dict — dictionary.
  2. string (one or more values) — path in dictionary.

getUrlFromDict(dict, vararg string) url

Returns an url property from dictionary.

Arguments:

  1. dict — dictionary.
  2. string (one or more values) — path in dictionary.

getDictFromDict(dict, vararg string) dict

Returns an dict property from dictionary.

Arguments:

  1. dict — dictionary.
  2. string (one or more values) — path in dictionary.

getArrayFromDict(dict, vararg string) array

Returns an array property from dictionary.

Arguments:

  1. dict — dictionary.
  2. string (one or more values) — path in dictionary.

getOptStringFromDict(string, dict, vararg string) string

Returns an optional string property from dictionary.

Arguments:

  1. string — fallback value if property does not exist or a property value is not a string.
  2. dict — dictionary.
  3. string (one or more values) — path in dictionary.

getOptNumberFromDict(number, dict, vararg string) number

Returns an optional number property from dictionary.

Arguments:

  1. number — fallback value if property does not exist or a property value is not a number.
  2. dict — dictionary.
  3. string (one or more values) — path in dictionary.

getOptIntegerFromDict(integer, dict, vararg string) integer

Returns an optional integer property from dictionary.

Arguments:

  1. integer — fallback value if property does not exist or a property value is not an integer.
  2. dict — dictionary.
  3. string (one or more values) — path in dictionary.

getOptBooleanFromDict(boolean, dict, vararg string) boolean

Returns an optional boolean property from dictionary.

Arguments:

  1. boolean — fallback value if property does not exist or a property value is not a boolean.
  2. dict — dictionary.
  3. string (one or more values) — path in dictionary.

getOptColorFromDict(color, dict, vararg string) color

Returns an optional color property from dictionary.

Arguments:

  1. color — fallback value if property does not exist or a property value is not a color.
  2. dict — dictionary.
  3. string (one or more values) — path in dictionary.

getOptColorFromDict(string, dict, vararg string) color

Returns an optional color property from dictionary.

Arguments:

  1. string — fallback value if property does not exist or a property value is not a color.
  2. dict — dictionary.
  3. string (one or more values) — path in dictionary.

getOptUrlFromDict(url, dict, vararg string) url

Returns an optional url property from dictionary.

Arguments:

  1. url — fallback value if property does not exist or a property value is not an url.
  2. dict — dictionary.
  3. string (one or more values) — path in dictionary.

getOptUrlFromDict(string, dict, vararg string) url

Returns an optional url property from dictionary.

Arguments:

  1. string — fallback value if property does not exist or a property value is not an url.
  2. dict — dictionary.
  3. string (one or more values) — path in dictionary.

getOptArrayFromDict(dict, vararg string) array

Returns an array value from dict if exist or empty array otherwise.

Arguments:

  1. dict — dictionary.
  2. string (one or more values) — path in dictionary.

getOptDictFromDict(dict, vararg string) dict

Returns an dict value from dict if exist or empty dict otherwise.

Arguments:

  1. dict — dictionary.
  2. string (one or more values) — path in dictionary.

len(dict) integer

Counts the number of elements in a dictionary.

Argument: dict — dictionary.

getDictKeys(dict) array

Return a collection containing just the keys of the dictionary.

Argument: dict — dictionary.

getDictValues(dict) array

Return a collection containing just the values of the dictionary.

Argument: dict — dictionary.

Number formatting

Function

Description

decimalFormat(integer, string) string

Returns a string value from an integer using format.

Arguments:

  1. integer — integer value to format.
  2. string — number format, similar to ICU-like.

decimalFormat(number, string) string

Returns a string value from an number using format.

Arguments:

  1. number — number value to format.
  2. string — number format, similar to ICU-like.

decimalFormat(integer, string, string) string

Returns a string value from an integer using format and locale.

Arguments:

  1. integer — integer value to format.
  2. string — number format, similar to ICU-like.
  3. string — locale.

decimalFormat(number, string, string) string

Returns a string value from an number using format and locale.

Arguments:

  1. number — number value to format.
  2. string — number format, similar to ICU-like.
  3. string — locale.

Learn more

You can discuss topics of interest in the DivKit user community in Telegram: https://t.me/divkit_community_en.

DivKit Repository