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: Re: Question about time formatting
From: Maren Purves <m.purves@jach.hawaii.edu>
To: Eric Norum <wenorum@lbl.gov>
Cc: EPICS Tech-Talk <tech-talk@aps.anl.gov>
Date: Mon, 14 Jan 2013 11:29:55 -1000
Something like this?

strftime(filename, sizeof(filename),
                    "/%Y%m%d/", gmtime( &now ) )

(we're reusing the filename here, this part is the UT date.
It really is
length=strftime etc.)

Aloha,
Maren

Eric Norum wrote:
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,




References:
Question about time formatting Eric Norum

Navigate by Date:
Prev: Question about time formatting Eric Norum
Next: problem about edm widget Silver
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: Question about time formatting Eric Norum
Next: problem about edm widget Silver
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 ·