Time Conversion Functions from Time.g


The DataHub works in two different time standards:

    Windows DATE (VT_DATE) is the number of days, as an 8-byte float since December 30, 1899. The fractional part is unsigned, so 6 a.m. December 29, 1899 would be represented as -1.25.

    Unix time is the number of seconds since 12 a.m. January 1, 1970. It is a signed 4-byte integer. Negative times have no meaning.

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, and are available to any DataHub script that requires or includes the Time.g file, using one of these statements:

    require ("Time");

    include ("Time");

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 a local Unix time into UTC.
UnixTimeToWindowsTime - converts from Unix time to Windows time.
UnixUTCToLocal - converts a UTC Unix time into local time.
WindowsLocalToUTC - converts a local Windows time into UTC.
WindowsTimeToUnixTime - converts from Windows time to Unix time.
WindowsUTCToLocal - converts a UTC Windows time into local time.