Dear Community,
I needed to implement a process that sets a new "DateLastWorked" based on the ExitDate of a person.
The new DateLastWorked must be set to the end of the day, based on ExitDate, i.e. 09.10.2018 23:59:00.000
I chose the "HandleObjectComponent - Update" as process step.
I had a few problems implementing this easy function.
- It seems that the object layer doesn't correct the input-date to the correct database time (UTC).
When I calculated the example value of "09.10.2018 23:59:00.000" it was written 1:1 to the database.
Function to set the new variable:
values("DateLastWorked") = Person.GetValue("ExitDate").Date.Date.AddMinutes(-1).AddDays(1)
That has, of course the effect that the wrong date is shown in the manager/web and the wrong date is transmitted to the target systems.
What I then did was trying to calculate the utc time in the pre-script of the process. - Sadly the function I used for that seems to be bugged in the context of a process (It works just fine in a custom script)
values("DateLastWorked") = DBVal.ToUniversalTime(Person.GetValue("ExitDate").Date.Date.AddMinutes(-1).AddDays(1),Connection.TimeZone)
What works in an custom-script (Input 23:59 = 21:59 if local time is German time with daylight-saving "UTC+2") seems not to work in the context of a process.
Input and output of that function are the same. 23:59 = 23:59.
What works is that function that should work identical:
values("DateLastWorked") = Person.GetValue("ExitDate").Date.Date.AddMinutes(-1).AddDays(1).Add(-Connection.TimeZone.BaseUtcOffset)
Now I'm confused about the behavior and I have two questions:
- Is it correct that the object layer doesn't correct date values to the database time zone when using the "HandleObjectComponent - Update" process-component?
- Why are the two function calls have different results when they should do the same?
I have tested the behavior in 7.1.2 and 8.0.2 with same results.