Timestamp functions

This page describes the additional set of predefined Jsonnet functions for the Data Transformer Script task available in Application Integration.

Before you begin

To use the following predefined functions, you must import the functions library in your script. Importing the functions library lets you use both the standard Jsonnet functions and the predefined Data Transformer functions.

Application Integration supports Jsonnet functions library v0.20.0. For information about the Jsonnet standard functions, see Jsonnet Standard Library.

Date Format

Syntax
        
dateFormat(timestamp, format_string, timezone, current_format)
      
DescriptionFormats a timestamp according to the specified format_string.
Input parametertimestamp: The input timestamp.

format_string: The new timestamp format. See Supported timestamp format elements for a list of format elements that can be used to form the new timestamp format string.

timezone: The timezone of the provided input timestamp. Default value is UTC.

current_format: The format which would be used to parse the provided input timestamp. Default value is E (epoch).

Return typeSTRING
OutputReturns a new string after converting the input timestamp based on the specified format_string.

Supported timestamp format elements

The following table lists the supported format elements for the dateFormat() function:

Format elementDescriptionExample
YYYY4-digit year.2023
YYLast 2 digits of the year.23
MMMMName of the month in titlecase.March
MMMAbbreviated name of the month in titlecase.Mar
MMMonth from 01 to 12.03
MMonth from 1 to 12.3
DDDDName of the day in titlecase.Monday
DDDAbbreviated name of the day.Mon
DDDay from 01 to 31.06
DDay from 1 to 31.6
HHHour in 24 hour format from 00 to 23.15
hhHour in 12 hour format from 01 to 12.03
hHour in 12 hour format from 1 to 12.3
mmMinute from 00 to 59.04
mMinute from 0 to 59.4
ssSeconds from 00 to 59.08
sSeconds from 0 to 59.8
FFFFFFFFFFractional seconds with 9 digits, including zeros, on the right of the specified digits.00.123456789
FFFFFFFFFractional seconds with 8 digits, including zeros, on the right of the specified digits.00.12345678
FFFFFFFFractional seconds with 7 digits, including zeros, on the right of the specified digits.00.1234567
FFFFFFFractional seconds with 6 digits, including zeros, on the right of the specified digits.00.123456
FFFFFFractional seconds with 5 digits, including zeros, on the right of the specified digits.00.12345
FFFFFractional seconds with 4 digits, including zeros, on the right of the specified digits.00.1234
FFFFractional seconds with 3 digits, including zeros, on the right of the specified digits.00.123
FFFractional seconds with 2 digits, including zeros, on the right of the specified digits.00.12
FFractional seconds with 1 digits, including zeros, on the right of the specified digits.00.1
fffffffffFractional seconds with 9 digits.987654321
ffffffffFractional seconds with 8 digits.98765432
fffffffFractional seconds with 7 digits.9876543
ffffffFractional seconds with 6 digits.987654
fffffFractional seconds with 5 digits.98765
ffffFractional seconds with 4 digits.9876
fffFractional seconds with 3 digits.987
ffFractional seconds with 2 digits.98
fFractional seconds with 1 digits.9
ttMeridian indicator (morning or evening). When formatting, this is either AM or PM.PM
tShort meridian indicator (morning or evening). Maps to the lowercase am or pm.pm
KTime zone name.PST
kkTime zone in ±xx:xx format.-8:00:00
kTimezone in ±xxxx format.-8000

Is Leap Year

Syntax
        
isLeapYear(year)
      
DescriptionChecks if the given year is a leap year.
Input parameteryear: The input year (real number).
Return typeBOOLEAN
OutputReturns TRUE if the year is a leap year and FALSE otherwise.

Now In Millis

Syntax
        
nowInMillis()
      
DescriptionReturns the current Unix epoch time of an integration in milliseconds.
Input parameterN/A
Return typeINT64
OutputReturns the current Unix epoch time in milliseconds.

Recommendation