Re: [ROOT] Conversion of seconds to SQL formatted time

From: Robert Hatcher (rhatcher@SLAC.stanford.edu)
Date: Mon Nov 18 2002 - 17:25:27 MET


On Mon, 18 Nov 2002, Rene Brun wrote:
> On Sun, 17 Nov 2002, Aamer Rauf wrote:

> > I have UNIX time in seconds since 1970 or whatever. I need to
> > convert that into SQL formatted time. How could I do that. The
> > unix time in seconds is not the present time rather it could be
> > yesterday's or a year old time.

> see class TDatime

Actually in this case TTimeStamp might be a better choice.  TDatime
has a data member:

   UInt_t     fDatime;            //Date (relative to 1995) + time

and a constructor that takes such a a UInt_t, but this isn't the
normal POSIX "epoch" start (where t=0) and thus to use it Aamer
must make an offset subtraction.  TTimeStamp accepts a time_t
(+ ns value) and using the "s" option for AsString() will return
the standard SQL format.

-robert

Robert W. Hatcher   | rhatcher@fnal.gov   630-840-3102
FNAL CD/CP (MINOS)  | MS 220, PO Box 500, Batavia IL 60510



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:18 MET