Forum Discussion

SASafety's avatar
SASafety
Qrew Member
2 years ago

Shifting Timezones using Pipelines

I'm having issues handling timezone alterations in Pipelines and would love some help. I currently have a form that allows a user to input a time in local time (we are blind to who that user is), select a timezone, and submit. What I would like is to convert that given local time with the timezone to UTC.

My current approach is to take the time argument and add a time delta to account for the UTC conversion like so:

Time received: 18:02 PST
Time - UTC: 2:02 UTC + 1

In pipelines, that would mean:

{{time_rec}} + time.delta(hours=({{time_rec}} - {{time_rec | timezone('America/Los Angeles')}} ))

Or at least, I was hoping that this would work, since the application's time setting is UTC by default, so taking the differential between the given time and the timezone should provide the proper delta in hours.

I would like to use Pipelines for this rather than a formula field to automatically account for Daylight savings time throughout the year and in multiple timezones.


That would make the function:

18:02 + time.delta(18:02 - 10:02) = 18:02 + 8 = 2:02 +1d.
******

I'm getting an error, the pipeline doesn't seem to like my Jinja operations and won't execute. Does you have any suggestions for how to fix the syntax or a better approach?



------------------------------
Matt Rand
------------------------------
No RepliesBe the first to reply