Temporal Objects Manipulation

To get a part of a temporal variable:

$ year(2016.02.14);
2016

$ monthOfYear(2016.02.14);
2

$ dayOfMonth(2016.02.14);
14

$ x=01:02:03.456;
$ hour(x);
1

$ minuteOfHour(x);
2

$ secondOfMinute(x);
3

$ x mod 1000;
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;
2015.01M

$ 2018.02.17+100;
2018.05.28

$ 01:20:15+200;
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;
00:09m

$ 00:00:01-2;
23:59:59

$ 23:59:59.900+200;
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");
2017.01.23

$ temporalAdd(2016.12M,2,"M");
2017.02M

$ temporalAdd(13:30m,-15,"m");
13:15m