Hi.
We are in the beginning stages of a project that will need to handle time-based calculations in different timezones, but in a singular Ignition Project.
For example, let’s say I need to trigger a Python script at midnight, but I need to trigger the script at midnight UTC+0, then UTC+2, UTC+8 etc.
The naive solution would be just storing the number of hours relative to UTC needed for each calculation/script - but there are things like Daylight Savings Time & more. (yourcalendricalfallacyis.com)
I know Ignition handles things like Daylight Savings Time automatically, but I can’t figure out how to use it in an expression.
If I write midnight(now(0))
, I get midnight for the Gateway’s timezone only.
An ideal scenario would be to just specify for which timezone I want to get midnight for - like midnight(now(0), "Europe/Berlin")
If it weren’t for Daylight Savings Time, I would just “hardcode” the value.
But that’s not a good idea.
Also, as far as I can tell, Perspective Session can either use the Gateway’s timezone, the client’s timezone or a timezone picked by hand.
The problem is, we need to be able to change this value on the frontend, so the operators can switch between their local time & the time of the project they are monitoring at the moment, so for example the Time Series Chart displays the time accordingly.
To summarize, our problem is:
- we can’t just hardcode time offsets for the calculations & scripts, we need a way to get that offset from a library, so we can be sure that things like Daylight Savings Time are taken care of
- we need to be able to change in which timezone the time on a graph is displayed dynamically on the frontend
Thanks for any suggestions!
P.S.: I know that a “cron” feature is already on the roadmap, but unless 8.1.6 is coming out by the end of the week, I need to solve this in a different way for now
P.P.S.: Ideally, we would like to not use Python for this, since it is by far not the fastest language & we will need to run a lot of calculations that are more complex than my simplified midnight example