timestamps

From: Chiara Zampolli <Chiara.Zampolli_at_bo.infn.it>
Date: Fri, 15 Feb 2008 23:51:27 +0100


Dear rooters,

    I have some (probably trivial) doubts concerning how to retrieve timestamps from a given local time. My local time is CET, so what I do to get the timestamp according to GMT is:

[pcalishuttle01] /home/shuttle/Chiara > date
Fri Feb 15 23:28:16 CET 2008
[pcalishuttle01] /home/shuttle/Chiara > date +%s
1203114501
[pcalishuttle01] /home/shuttle/Chiara > root -l
*** DISPLAY not set, setting it to pcalice134.cern.ch:0.0 root [0] TTimeStamp tmp(2008,2,15,23,28,00,0,kFALSE) root [1] tmp.GetSec()
(const time_t)(1203114480)

The slight difference between 1203114501 and 1203114480 should be of course due to the delay in time while typing... BTW, I'm not completely sure that the timestamp I get in this way, specifying kFALSE which means "this is my local time" corresponds to the GMT time, also because I'm comparing it with the return of date, but I'm not sure that "date" returns the timestamp corresponding to GMT. Moreover:

root[2] TTimeStamp tmp1(1203114480)
root [3] tmp1.Print()
Date/Time = Fri, 15 Feb 2008 23:28:00 +0000 (GMT) + 0 nsec

as if it was 23:28 in Greenwich (GMT!!!) and not here in Geneva (CET time zone)!!, and

root[4] TTimeStamp tmp2(2008,2,15,23,28,00,0,kTRUE, -3600) root [5] tmp2.GetSec()
(const time_t)(1203114480)

Probably what I would better do is:

root [0] TTimeStamp tmp2(2008,2,15,23,28,00,0,kFALSE) root [1] tmp2.GetSec()+TTimeStamp::GetZoneOffset() (const time_t)(1203110880)

which is 3600 s = 1 h less then the timestamp I got before, and so could be related to the Greenwich time:

root [2] TTimeStamp tmp3(1203110880)
root [3] tmp3.Print()
Date/Time = Fri, 15 Feb 2008 22:28:00 +0000 (GMT) + 0 nsec

So, as far as I have understood, the timestamps should be universal, in the sense that each of them corresponds to only one time in GMT, but to many times if we consider many local time zones. But I'm getting confused in what I should set, kTRUE/kFALSE, an offset or not, and in how to retrieve the correct timestamp. In other words, if I'm looking for something that was stored with its timestamp, which is its identified and was computed according to GMT, but I'm starting from a CET time, what should I do?

Thanks in advance for any clarification. Regards,

       chiara

. Received on Fri Feb 15 2008 - 23:52:48 CET

This archive was generated by hypermail 2.2.0 : Sun Feb 17 2008 - 23:50:01 CET