EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: RE: EPICS UTC Time conversion
From: "Allison, Stephanie" <[email protected]>
To: "'Eric Norum'" <[email protected]>, "[email protected] Talk" <[email protected]>
Date: Tue, 16 Apr 2013 14:54:42 -0700
Hi Eric,

Perhaps force the isdst flag to 0 in between calls:

> epicsTimeToGMTM(&tm, &nsec, &timestamp);
tm.tm_isdst = 0;
> epicsTimeFromTM(&utc, &tm, 0);

Stephanie

> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On Behalf
> Of Eric Norum
> Sent: Tuesday, April 16, 2013 1:18 PM
> To: [email protected] Talk
> Subject: EPICS UTC Time conversion
> 
> 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 (tm);
> unsigned long nsec;
> char cbuf[80];
> ......
> epicsTimeToGMTM(&tm, &nsec, &timestamp);
> 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:
> 
> 	date -u -r 1366124582
> 	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?
> 
> --
> Eric Norum
> [email protected]



Replies:
Re: EPICS UTC Time conversion Eric Norum
References:
EPICS UTC Time conversion Eric Norum

Navigate by Date:
Prev: Re: EPICS UTC Time conversion Eric Norum
Next: Re: EPICS UTC Time conversion Eric Norum
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: EPICS UTC Time conversion Eric Norum
Next: Re: EPICS UTC Time conversion Eric Norum
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <20132014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 20 Apr 2015 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·