1 is the time in EST HH:mm tt [ input value example : 5:00 pm ]
the second is the gmt +/- of the client [ input value example : -2:00 ]
ignoring daylight saving issues, the goal is to take the time and display it in the clients local time.
for example , if i have a project starting at 6pm EST, and a client in a timezone of -1 gmt,
EST is -5gmt so i know the local time is 2pm for the client.
here is formula i use so far for int32 ( did this as a test )
[Assign] X = -5 (EST var )
[Assign] Y = -1 ( Local time )
[Assign] Result = math.abs(x - (y))
[If] (y.tostring).contains(“-”)
Result = z - Result
Else
Result = z + result
This seems to return the correct values, but its in int32. I cant seem to get it working with dateTime.
problem is some of the meetings are like, 16:15 etc, so int wont cut it. Any suggestions ?
Not quite. There is not .SubtractHours() function. There is only .Subtract() or .AddHours()
.Subtract() requires a Timespan while .AddHours() just requires a number
There’s probably a number of ways to do this, but you could just convert the time to a DateTime with CDate(timestring) or Convert.ToDate(timestring). Then, you can use .AddHours()
projectTime <as DateTime> = Convert.ToDate("17:00")
Result = projectTime.AddHours(-1*var3)
So it should look like projectTime.AddHours(-3), and that will subtract the hours. As far as the math you are doing on the var1 and var2, I’m not completely sure why you are doing that, but hope the other stuff is helpful.
EDIT: also since it’s a DateTime it will include the date, so use .ToString("hh:mm") to output only the time.
var2 = -2
Result = Convert.ToDate("17:00").ToUniversalTime.AddHours(var2)
Essentially, you know the client is -2 utc (whatever it may be), so by converting your project time to utc, you can subtract from that to find the client’s time.