I have an application that creates log files with names based on the current time. To avoid problems with DST changes I want to use UTC. Here's the code I'm now using:
/*
* This thread rotates the log files every half hour.
*/
static void
logFileRotater(void *arg)
{
epicsTimeStamp now;
struct tm tm;
unsigned long nsec;
int idx;
for (;;) {
epicsTimeGetCurrent(&now);
epicsTimeToGMTM(&tm, &nsec, &now);
epicsTimeFromTM(&now, &tm, nsec);
idx = (logNameIndex + 1) % LOGNAME_COUNT;
epicsTimeToStrftime(logName[idx], sizeof logName[0], "%F_%T", &now);
logNameIndex = idx;
epicsThreadSleep(IRM_LOGFILE_DURATION);
}
}
This works, but swapping back and forth between time representations like that seems a little clumsy. Is there a better approach I could use to convert an EPICS time stamp into a UTC date and time?
Thanks,