I am a Node-RED and JS newbie that would greatly appreciate some assistance on a dashboard issue I am trying to solve.
I have some timestamps stored as UTC datetime objects that I would like to show in a ui-table column. This thread helped me apply my desired formatting to show in the table, but I cannot seem to get timezone offsetting to work. I can apply timezone offset using JSONata expressions, but not sure if there is a way to embed that into the msg.ui_control JSON. I have tried adding a "timezone" parameter to no avail:
The tabulator documentation says the luxon.js library is required for date/time formatting but it seems the output formatting works with the built-in moment.js features. I am hoping there is a way to do the same for timezone offsets?
As I understand it, moment will convert UTC timestamps to the local of the browser running it. The idea is that a timestamp right now would display in my timezone (America/New_York) but on your device it would use your timezone "Australia/Brisbane".
Remember, formatting the output is different than converting it to a different time zone. If you want it to display in a different timezone then yes, you will have to do what the tabulator documentation requires.
Would this be a matter of installing luxon.js and importing it via functionGlobalContext in settings.js? I note that usually you would need to then do a global.get() in a function node, but since the dependency is in the ui-table node, how would that work?
Okay, I gave it a go. I was able call luxon functions in a function node by invoking the global context variable but unfortunately I cannot get ui-table itself to pick it up for applying timezone offsets. I tried using the formatterParams timezone parameter specified in the tabulator documentation and also tried calling luxon in a custom formatter function using global.get(). Neither seem to work and doing the latter actually breaks the entire ui_control message.
The (kind of annoying) workaround I have at the moment is to store my datetime in local time and convert it back to UTC when I need to pass it to somewhere else that is expecting UTC.