Chapter 10. Time Conversion Functions from Time.g

Table of Contents
GetCurrentWindowsTime — returns the current clock time in Windows time format.
PointGetUnixTime — gets the Unix time stamp from a point.
PointGetWindowsTime — gets the Windows time stamp from a point.
PointMetadata — queries a point for its metadata structure.
UnixLocalToUTC — converts from local Unix time to UTC.
UnixTimeToWindowsTime — converts from Unix time to Windows time.
UnixUTCToLocal — converts from UTC Unix time to local time.
WindowsLocalToUTC — converts from local Windows time to UTC.
WindowsTimeToUnixTime — converts from Windows time to Unix time.
WindowsUTCToLocal — converts from UTC Windows time to local time.

The DataHub program works in two different time standards:

In these functions, Unix time uses the traditional Unix time plus a number of nanoseconds. Since this cannot be expressed as a single 4-byte integer, we express it as an 8-byte floating point number where the fractional part adds accuracy. This accuracy is ideally measured down to the nanosecond, but in practise relies on the accuracy of the operating system clock. In Windows, this means milliseconds.

Unix time is important because it is the time format used in the Gamma functions time, mktime, localtime and date. It is also the time format used when explicitly specifying a time stamp on a point in Unix.

Windows time is the internal time representation used by DataHub points.

The functions listed here are created in the script Time.g located in the require folder of your DataHub installation. They are available to any DataHub script that requires or includes the Time.g file, using one of these statements: