Я работаю над проектом GPS, для этого хочу добавить временные метки (UTC) после каждого получения данных gps. Как я могу конвертировать IST в UTC в C? Я вычитаю 5:30 часов в tv.tv_sec, но это не правильный путь. Есть ли какая-нибудь функция для получения UTC от IST?Как преобразовать время IST в UTC в C (Ubuntu)?
#define MAX_STRING_SIZE 50 /* for TimeStampsForServer */
int fnTimeStampsForGpsData()
{
struct timeval tv;
struct tm *ptm;
char TimeString[MAX_STRING_SIZE];
long MicroSeconds;
/**
* Obtain the time of day, and convert it to a tm struct.
*/
gettimeofday (&tv, NULL);
tv.tv_sec -= 19800; /* Number of seconds (5:30) */
ptm = localtime (&tv.tv_sec);
/**
* Format the date and time, down to a single second.
*/
strftime (TimeString, sizeof (TimeString), "%Y-%m-%d %H:%M:%S", ptm);
/**
* Copying microseconds.
*/
MicroSeconds = tv.tv_usec;
/**
* Print the formatted time, in seconds, followed by a decimal point
* and the microseconds.
*/
printf ("%s.%06ld\n", TimeString, MicroSeconds);
return 0;
}