Time and PITIMESTAMP Structure

The PI-API continues to support what is termed the PI for OpenVMS time, which is a 32-bit integer quantity representing the number of seconds since midnight, 01-Jan-70 in local time. Support for timestamps smaller than one second requires a new data type, which is outlined in this section.

The PITIMESTAMP structure has a field for each common part of time measurement: year, month, day, hour, minute, second and timezone information as shown below. This structure is similar to the ANSI standard tm structure, except that seconds are rendered as a double-precision floating point number and the tzinfo member is a bit field which is set and read internally.

The members of the PITIMESTAMP structure always render time as local time, corrected for standard or daylight savings time, depending on which is in effect.

typedef struct _PITIMESTAMP {

int32 month; /* 1-12 */ 

int32 year; /* four digit */ 

int32 day; /* 1-31 */ 

int32 hour; /* 0-23 */ 

int32 minute; /* 0-59 */ 

int32 tzinfo; /* timezone information */ 

double second; /* 0-59.99999999.... */ 

} PITIMESTAMP;

New time functions have been added to retrieve sub-second time values from PI, and to put sub-second timestamps into PI. These functions populate and retrieve from the PITIMESTAMP structure.

To work with sub-second times, your program must declare one or more variables of type PITIMESTAMP. You pass the address of the PITIMESTAMP structure to the new pitm functions in order to manipulate times.

Functions that add values to PI pass a pointer to the PITIMESTAMP structure. If a NULL pointer is passed for the timestamp, the current time will be used without subseconds. The PITIMESTAMP value will be send as the current UTC time to the PI server. This behavior is different than the standard functions which use the PI server local time when a timestamp of zero is used

Enabling Operational Intelligence