I'm trying to convert an EPICS time stamp into a string -- but in UTC, not the local time zone.
Here's my failing attempt: epicsTimeStamp timestamp; epicsTimeStamp utc; struct tm ™; unsigned long nsec; char cbuf[80]; …… epicsTimeToGMTM(&tm, &nsec, ×tamp); epicsTimeFromTM(&utc, &tm, 0); epicsTimeToStrftime(cbuf, sizeof cbuf, "%F_%T", &utc);
The resultant string is one hour off. It's as if the routines above are trying to apply daylight savings time correction to UTC.
For example, consider the following POSIX time stamp: Tue Apr 16 15:03:02 UTC 2013
If, in the above code, I set timestamp.secPastEpoch = 1366124582 - POSIX_TIME_AT_EPICS_EPOCH; timestamp.nsec = 0; The resultant string is: 2013-04-16_16:03:02
See how the hours are '16' instead of '15'. So, what's the trick to getting a true UTC time string from an EPICS time stamp? |