Re: [ROOT] SetTimeOffset

From: Fons Rademakers (Fons.Rademakers@cern.ch)
Date: Thu Jan 25 2001 - 19:30:44 MET


Hi Damir, Jayoung,

   much simpler, just do:

TDatime t(2000,1,1,0,0,0);
gStyle->SetTimeOffset(t.Convert());


Cheers, Fons.




Damir Buskulic wrote:
> 
> Hi Jayoung,
> 
> The time you have to use is the UTC time, which is expressed in seconds
> since a starting point, back in the seventies. There exists a routine in
> C called strptime that does just this, convert a string describing a
> time in human readable form, but it is not known to the interpreter
> since it doesn't seem to be standard C/Posix.
> This is unfortunate and I acknowledge it. There are basically two ways
> to circumvent this.
> 
> 1) Make a structure of type struct tm which is a standard structure
> containing time information, fill it and convert it :
> 
> #include <time.h>
> struct tm* stime;
> stime = new tm;
> stime->tm_sec=0; // seconds (0-61)
> stime->tm_min=0; // minutes (0-59)
> stime->tm_hour=0; // hours after midnight (0-23)
> stime->tm_mday=1; // day of the month (1-31)
> stime->tm_mon=0; // month since january (0-11)
> stime->tm_year=101; // year since 1900
> stime->tm_wday=0; // day of the week (0-6)
> stime->tm_yday=0; //number of the day in the year (0-365)
> stime->tm_isdst=0; // summer/winter hour flag
> 
> my_time = mktime(stime);
> 
> That's it !
> 
> 2) write a small C code that will use strptime and make a shared lib of
> it to be able to use it in the interpreter.
> I'll let you look in a good C book for more info about strptime
> 
> Damir
> 
> Jayoung Wu wrote:
> >
> > Dear Rooters,
> >
> > I'd like to set time offset to 01/01/2000 0:00 am.
> >
> > time_t my_time;
> > gStyle->SetTimeOffset(my_time);
> >
> > What value should I assign for my_time?
> >
> > ---
> > Thanks,
> > Jayoung
> 
> --
> =====================================================================
> | Damir Buskulic                  | Universite de Savoie/LAPP       |
> |                                 | Chemin de Bellevue, B.P. 110    |
> | Tel : +33 (0)450091600          | F-74941 Annecy-le-Vieux Cedex   |
> | e-mail: buskulic@lapp.in2p3.fr  | FRANCE                          |
> =====================================================================
> mailto:buskulic@lapp.in2p3.fr

-- 
Org:    CERN, European Laboratory for Particle Physics.
Mail:   1211 Geneve 23, Switzerland
E-Mail: Fons.Rademakers@cern.ch              Phone: +41 22 7679248
WWW:    http://root.cern.ch/~rdm/            Fax:   +41 22 7677910



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:34 MET