Is there a way to set the designer timezone context to match the gateway timezone context? ... and is there a reason it does not?
On my system executing system.date function using the designer Script Console defaults to using UTC, whereas the same script when run from the gateway context default to using the configured gateway timezone (CDT). This difference in behavior is baffling to me and a hinderance to testing. Is it a feature or a flaw?
In my mind running a script from the designer scripting console should assume the gateway context (and timezone) and output the same as if run in a gateway event script but that doesn't appear to be the case.
Example script:
TestDate = system.date.getDate(2022, 8, 4)
print 'Test Date: {}'.format(today)
now = system.date.now()
print 'Now: {}'.format(now)
print 'DayOfMonth: {}'.format(system.date.getDayOfMonth(now))
print 'Hour of day: {}'.format(system.date.getHour24(now))
Results from designer script console:
>>>
Today: Sun Sep 04 00:00:00 UTC 2022
Now: Tue Oct 04 20:44:03 UTC 2022
DayOfMonth: 4
Hour of day: 20
Results from gateway timer script (pulled from wrapper.log), not exactly time synced:
INFO | jvm 1 | 2022/10/04 16:03:59 | Today: Sun Sep 04 00:00:00 CDT 2022
INFO | jvm 1 | 2022/10/04 16:03:59 | Now: Tue Oct 04 16:03:59 CDT 2022
INFO | jvm 1 | 2022/10/04 16:03:59 | DayOfMonth: 4
INFO | jvm 1 | 2022/10/04 16:03:59 | Hour of day: 16
Note the difference in output of the system.date functions system.date.getDate, system.date.getHour24 etc..
My specific use case is attempting to determine a date (date-time) for the start of a day and one for the end of the same day, allowing for 23 hour and 25 hour days due to daylight savings. To use as a range for a historical data query and export. I need to trigger a script shortly after midnight and automatically export data for the previous day (23-25 hours) to a set of files. I need that to run in the context of the gateway's local time not UTC.
My development/testing started using the script console and I was struggling to get the right date math to work out when everything was defaulting to UTC, then later realized the scripts behaved differently when run from the gateway context (gateway events).
Ignition 8.1.19