g+
g+ Communities
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  <2013 Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <2013
<== Date ==> <== Thread ==>

Subject: Question about time formatting
From: Eric Norum <wenorum@lbl.gov>
To: EPICS Tech-Talk <tech-talk@aps.anl.gov>
Date: Mon, 14 Jan 2013 12:03:26 -0800
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,
-- 
Eric Norum
wenorum@lbl.gov



Replies:
Re: Question about time formatting Maren Purves

Navigate by Date:
Prev: Stay in touch with me through LinkedIn Santosh Aditya
Next: Re: Question about time formatting Maren Purves
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <2013
Navigate by Thread:
Prev: Stay in touch with me through LinkedIn Santosh Aditya
Next: Re: Question about time formatting Maren Purves
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  <2013
ANJ, 14 Jan 2013 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· EPICSv4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·