Greetings! How to convert the string time to PITime object in C++?
I mean, for e.g, the string "16-Dec-2011 10:12:00" converted to PITime object.
Eliyas - usually I just pass the string to the PI SDK call. Anyhow, a way to fill the PITime object with your string would be:
_bstr_t dt = "16-Dec-2011 10:12:00";
Hope this helps.
Brilliant! Thanks Andreas.
You can also use the PITimeFormat object instead, which inherits from PITime. I like it because you can initialize it very simply with its InputString, and use any accepted "PI Time" notation. Then like the PITime object, you can use its LocalDate, UTCFileTime, UTCSeconds properties - or simply use the OutputString to see a nicely formatted date/time string.
pTime->InputString = "*-1d";
//pTime->InputString = "16-dec-11 12:34:56";
//pTime->InputString = "t";
// Do something with pTime->LocalDate
// or pTime->UTCFileTime
// or pTime->UTCSeconds
// or pTime->OutputString
cout << pTime->OutputString;
Retrieving data ...