Showing results for 
Search instead for 
Did you mean: 

Problem converting U8 array to date-time string

Hi All,
How can I convert U8 array (time_t data type from C dll) to date time string?
A dll function that I am calling has a structure of string, integer and time_t as one of the parameters. Instead of passing cluster, I pass an array of U8 of the size that the structure should be. All the members of the strcuture and parsed correctly except the date/time.

Function Parameter:
typedef struct {
Int AlarmState ;
Int AlarmGrade ;
TCHAR AlarmMessage [100] ;
time_t AlarmTimeStamp ;

Total size = 4 + 4 + 100 + 4 = 112

Using Call Library Function, I set the parameter type to Array of U8 and size 112.

After the array is populated when the function is called, I have done the following to interpret date and time.
1) Using Extract Zero Terminated String.VI I converted U8 array (of size 4) to string.
2) Type casted string to integer (I32).
3) Swap bytes
4) Swap Words
5) Format Date/Time String.
Please see the attached screenshot for visual display of the above.
Ideas on why the year is incorrect?

0 Kudos
Message 1 of 2
Hi Mimansa,

Is it only the year that is incorrect? Also, where did you find that ABC\0 VI that you use 3 times? Did you make it or is it in a labview library somewhere?


0 Kudos
Message 2 of 2