ive seen so many examples using a time_t, but timestamp_t is baffling me... Im doing an assignment where we need to print out GPS data, and the gps device returns a type timestamp_t for its time stamp and its an epoch time. Ive tried using gmtime() to convert and strftime() but nothing is working on that type. It keeps telling me it cannot convert timestamp_t* to time_t if i try using them.
Anyone know of any function that can convert a timestamp_t to human readable time?
thanks
This site enter link description here Indicates it is a unix timestamp with a fractional part. Assuming this means the numbers to the left of the decimal are the number of seconds since 1/1/1970 and the 'decimal' component is a fractional part of one second, you could strip off the the integer component and use ctime():
#include <time.h>
time_t seconds;
timestamp_t ts = 1415000462.999000;
seconds = (time_t) timestamp_t;
printf("Time: %s\n", ctime(&seconds));
This of course ignores the fractional part of a second, but you should be able to handle that easily.