The function UPDATE_TIME replaces the time described by a DateTime with another specified Time.
This function takes two pieces of input: a base DateTime, and a Time. It outputs a DateTime: the base DateTime but with the time replaced by the information given by the input Time.
Declaration
UPDATE_TIME(base_datetime, new_time) -> new_datetime
Parameters
base_datetime (type: DateTime)
Any DateTime.
new_time (type: Date)
Any Time.
This is what will replace the time information in the given DateTime.
Return Values
new_datetime (type: DateTime)
The DateTime that results from taking the base DateTime and replacing the time with the one given by new_time.
Examples
Assume the example has access to the following DateTime and Date values:
example_date_and_time = {
"date": {
"day": 1,
"month": 4,
"year": 2021
},
"time": {
"hour": 16,
"minute": 14,
"second": 38,
"millisecond": 0
},
"timeZone": "UTC"
}
example_time = {
"hour": 5
"minute": 11
"second" : 55
"millisecond": 45
}
The following example takes the DateTime example_date_and_time, which describes 4:14pm, 38 seconds and 0 milliseconds on a particular date, and replaces the time with the information given by example_time, which describes the time 5:11am, 55 seconds and 45 milliseconds. Note that the resulting DateTime describes the same date and the same timezone, as did example_date_and_time. Only the time has changed:
UPDATE_TIME(example_date_and_time, example_time) = {
"date": {
"day": 1,
"month": 4,
"year": 2021
},
"time": {
"hour": 5,
"minute": 11,
"second": 55,
"millisecond": 45
},
"timeZone": "UTC"
}