Hi,
An API send me back information with Linux format time stamp as 32 bits Unsigned Integer like:
1689690756 which means "2023-07-18 14:32:36 UTC". In the parameter to retrieve that value, I set "Measurment" as follow:
<Measurement>
<Type options="time">number</Type>
</Measurement>
And the result is: "19556 days 14h 32m 36s". So, its ok for the hours but not for the date. I couldn't find any reference to Linux time in the "SLC_UM_DataMinerDevelopmentLibrary_REV030" manual. So, is there a way to handle linux time in parameters and translate them properly without going through a QAction which could do the job?
Hi Dominique,
As far as I know, there is no direct way of achieving this directly but it could be possible with either a QAction and using the C# DateTime object or alternatively if you do not want to use a QAction you could use a combination of Sequence and DateTime measurement option
You would in essence convert from Unix Time Stamp format to OLE Date format with a set of operations in the Sequence tag and then you would use the DateTime option to make it display as a Date Time in your parameter.
The mathematical expression you need is as follows:
OLE Automation Date = (Unix Timestamp / 86400) + 25569
Where 86400 is the number of seconds in a day and 25569 is the offset between the "origin" dates of each of the formats
Which would translate into
<Sequence noset="true">div:86400;offset:25569</Sequence>
Hi Dominique,
Linux stores time at the number of seconds since Jan 1, 1970 (epoch time). According to the documentation pointed by Koen:
The timestamp is stored internally as an OLE Automation date: a decimal number indicating the total number of days passed since Midnight 1899-12-30.
So I believe you will need to use a QAction that converts the epoch time to OLE Automation date.
You can use the following method to convert the uint to a DateTimeOffset object.
https://learn.microsoft.com/en-us/dotnet/api/system.datetimeoffset.fromunixtimeseconds?view=netframework-4.6.2#system-datetimeoffset-fromunixtimeseconds(system-int64)
This object can then be converted to the OLE format that dataminer is expecting using dateTimeOffset.UtcDateTime.ToOADate().
The option on the parameter must be set to “datetime” instead of “time” to correctly display the date.
Hi Dominique,
I don't think it's possible to use the epoch time without going through a QAction.
There is a measurement option datetime, but that option expects an OAdate double value.
Hi,
the option "time" will show a time duration, did you try the options "date", "datetime" or "timeofday" ?
Options are described here.
Thank you João,
This indeed a the simplest way so far to handle Linux Time Stamp. So, I apply:
div:86400;offset:25569
And:
number
Which gives the correct result:
19/07/2023 08:45:09, for instance