Building a project in Edge 7.9.13.
I have a table that I am using a script to fill in the Dataset from tags, The tags are from an array of UDTs in the PLC. Everything is working except one column.
In the PLC I am using 64 bit integers for the timestamps (UTC time in milliseconds.).
I have a start time, a stop time, and a duration time (stop-start in PLC). This is also a 64 bit integer.
When I display these in my table, the start and stop work fine, but the duration is off.
It looks to be off by the timezone offset. It there a way I can read this as just time and not datetime?
If you use the fromMillis function, you’ll likely get into trouble with the time zone differences, as that’s always interpreted as UTC. While getDate will give you the midnight of a date in the current timezone.
EDIT: sorry, didn’t notice this was scripting instead of expressions. Same principle should hold in python though, start from midnight in the current timezone, and add milliseconds to it.
From a script written long ago, on a PC far, far away…
# convert an integer value to a duration in h:m:s
def hms(typeIn, value):
import datetime
if typeIn=='min':
return str(datetime.timedelta(minutes=value))
if typeIn=='sec':
return str(datetime.timedelta(seconds=value))
if typeIn=='millis':
return str(datetime.timedelta(milliseconds=value))
valueIn = 110002
print hms('millis', valueIn)