How to handle timestamps with C++

Discussion created by GjermundOmholt on Jul 31, 2012
Latest reply on Jul 31, 2012 by charlie@osisoft.com



I try to use UpdateValues() and PIValues.Add() to add values to a point. From value source I got the UTC timestamp for each value represented by no. of seconds and milliseconds since 1.1.1980.


How do I add my UTC timestamp, including milliseconds, to the PiValues collection?


The TimeStamp parameter of Add() is poorly documented in the PI SDK Programming Reference regarding fractional seconds.


Here is my code so far:

          _variant_t varTimestamp;
          varTimestamp.vt = VT_R8;
          pVariantTime->dblVal = (double)seconds + SECONDSFROM1970TO1980 + (double)milliseconds/1000;
          spPIValuesToStore->Add(&varTimestamp, &varValue, NULL); 

Can anybody verify if this is correct? Is it possible to add fractional seconds this way?


Does PI consider the timestamp to be UTC or local time when using VT_R8?


Also, is PI SDK Programming Reference missing documentation of PITime and PITimeFormat?