Temporal Objects Manipulation

To get a part of a temporal variable:

year(2016.02.14);
// output: 2016

monthOfYear(2016.02.14);
// output: 2

dayOfMonth(2016.02.14);
// output: 14

x=01:02:03.456;
hour(x);
// output: 1

minuteOfHour(x);
// output: 2

secondOfMinute(x);
// output: 3

x mod 1000;
// output: 456

To adjust the value of a temporal variable with an amount in the same time unit, we can use operators '+' or '-':

2016.02M-13;
// output: 2015.01M

2018.02.17+100;
// output: 2018.05.28

01:20:15+200;
// output: 01:23:35

For temporal objects of data type minute, second, time, and nanotime, the internal integers representing these objects have a lower limit of zero and an upper limit of 1440-1, 86400-1, 86400000-1, and 86400000000000-1 respectively. If the internal integer representing one of these objects after adjustment is below 0 or above the corresponding upper limit, the final result corresponds to the remainder of dividing the internal integer by the corresponding upper limit.

23:59m+10;
// output: 00:09m

00:00:01-2;
// output: 23:59:59

23:59:59.900+200;
// output: 00:00:00.100

To adjust the value of a temporal variable with an amount in the same or a different time unit, we can use function temporalAdd

temporalAdd(2017.01.16,1,"w");
// output: 2017.01.23

temporalAdd(2016.12M,2,"M");
// output: 2017.02M

temporalAdd(13:30m,-15,"m");
// output: 13:15m
To combine date and time into one new variable, we can use function concatDateTime
concatDateTime(2019.06.15,13:25:10);
// output
2019.06.15T13:25:10

concatDateTime(2019.06.15 2019.06.16 2019.06.17,[13:25:10, 13:25:12, 13:25:13]);
// output
[2019.06.15T13:25:10,2019.06.16T13:25:12,2019.06.17T13:25:13]
We also provide functions related to date offset, for examples:
yearBegin(2011.06.02);
// output: 2011.01.01

yearEnd(2011.06.02);
// output: 2011.12.31

businessYearBegin(2011.06.02);
// output: 2011.01.03

businessYearEnd(2011.06.12);
// output: 2011.12.30

isYearBegin(2011.01.01);
// output: true

isYearEnd(2011.12.31);
// output: true

isLeapYear(2012.06.25);
// output: true

monthBegin(2016.12.06);
// output: 2016.12.01

monthEnd(2016.12.06);
// output: 2016.12.31

businessMonthBegin(2016.10.06);
// output: 2016.10.03

businessMonthEnd(2016.07.06);
// output: 2016.07.29

semiMonthBegin(2016.12.26);
// output: 2016.12.15

semiMonthEnd(2016.12.06,15);
// output: 2016.11.30

isMonthStart(2011.01.01);
// output: true

isMonthEnd(2011.12.31);
// output: true

daysInMonth(2012.12.02);
// output: 31

quarterBegin(2012.06.12);
// output: 2012.04.01

quarterEnd(2012.06.12);
// output: 2012.06.30

businessQuarterBegin(2012.06.12);
// output: 2012.04.02

businessQuarterEnd(2012.06.12);
// output: 2012.06.29

isQuarterStart(2011.01.01);
// output: true

isQuarterEnd(2011.12.31);
// output: true

week(2019.11.24);
// output: 2019.11.25

weekBegin(2019.11.24);
// output: 2019.11.18

lastWeekOfMonth(2019.11.01);
// output: 2019.10.28

weekOfMonth(2019.11.01);
// output: 2019.10.07

fy5253(2016.11.01);
// output: 2016.02.01

fy5253Quarter(2016.11.01);
// output: 2016.10.31

A time interval can be specified using duration. The time unit can be a time unit or a trading calendar.

duration("5M")
// output: 5M

duration("3XNYS")
// output: 3XNYS