I’m looking to create a custom string dropdown made from a list of local timestamps for the user. There are set amount of timestamps related to the object, so the generic timestamp filters don’t suit our needs.
I understand that there are:
Built-in filter widget that lets you specify a histogram and range.
Date and time picker widget.
But I would like to create a dropdown of specific local timestamps for the user. In order to do so, I would need one of these solutions, or another feature:
Some sort of method to cast an array of timestamps strings in Workshop.
Pass in the timezone offset of the user into the Function that creates a string of local timestamps.
For such a custom behaviour you could use typescript functions. You would have a string selector for the timestamps, another one for the list of timezones, and you would pass the selected values to a typescript function where you can cast the strings and have all the flexibility you need.
And you could get this list of timezones from another function which would rely on the moment.js library for instance (https://momentjs.com/timezone/docs/#/data-loading/getting-zone-names/).
I figured this would be the only way to do it. Ideally I’d like to grab the user’s timezone automatically and skip the extra string selector for the timezone, but there doesn’t seem to be a pathway to do that. For example the Date & Time Picker automatically displays a timezone on the Frontend
It is not possible to get the local timezone from typescript functions since they’re not executed in the browser. If it is not possible in Workshop for now, one hacky workaround could be to iframe a hidden Slate application which would get the local timezone in a Slate function and output it to the Workshop module.
For any future readers, I ended up going this route with a hidden slate embed. I grabbed the
Get the timezone name from running local javascript in the Slate/Advanced Code Widget
Slate.sendmessage() of the timezone name to Workshop
Pass the timezone name variable from Workshop as a parameter to a Function
Used the timezone name to convert the UTC timestamps to local time. This handles the correct offsets for shifted daylight savings time in historical dates as well, enabling me to have a local timestamp string selector.