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  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 
<== Date ==> <== Thread ==>

Subject: Re: EPICS UTC Time conversion
From: Andrew Johnson <anj@aps.anl.gov>
To: tech-talk@aps.anl.gov
Cc: Eric Norum <wenorum@lbl.gov>
Date: Tue, 16 Apr 2013 18:10:49 -0500
Hi Eric,

On 2013-04-16 Eric Norum wrote:
> date -u -r 1366124582
> Tue Apr 16 15:03:02 UTC 2013

This seems to work and is shorter and probably faster:

#include <stdio.h>
#include "epicsTime.h"

int main() {
    epicsTimeStamp timestamp;
    struct tm tm;
    unsigned long nsec;

    timestamp.secPastEpoch = 1366124582 - POSIX_TIME_AT_EPICS_EPOCH;
    timestamp.nsec = 0;
    epicsTimeToGMTM(&tm, &nsec, &timestamp);
    printf("%04d-%02d-%02d_%02d:%02d:%02d\n", tm.tm_year + 1900,
        tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec);
    return 0;
}

2103-03-16_15:03:02

- Andrew
-- 
It is difficult to get a man to understand something, when his salary
depends upon his not understanding it. -- Upton Sinclair

Replies:
Re: EPICS UTC Time conversion Eric Norum
References:
EPICS UTC Time conversion Eric Norum
RE: EPICS UTC Time conversion Allison, Stephanie
Re: EPICS UTC Time conversion Eric Norum

Navigate by Date:
Prev: RE: EPICS UTC Time conversion Kim, Kukhee
Next: Re: EPICS UTC Time conversion Till Straumann
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 
Navigate by Thread:
Prev: RE: EPICS UTC Time conversion Kim, Kukhee
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 
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 ·