Problem with TAxis:SetTimeFormat()


I want to plot an histogram with the date on the X axis. I’m using an offset to define the start of the histogram. Here is a simplified example of what I want to do:

TH1D *H = new TH1D("test","test",300,0,300); H->GetXaxis()->SetTimeDisplay(1); H->GetXaxis()->SetTimeFormat("%H:%M%F2013-02-14 00:00:00"); H->Draw();
As you can see I want the histogram to start at 2013-02-14 00:00:00
Instead of this, it starts at 2013-02-14 01:00:00.

Can you tell me why I have a 1 hour offset? I suspect that this is currently summer time and the date I’m providing is in the winter time. Is that right? If so, how can I compensate this effect?

Thank you

I think it’s indeed due to summer time handling and as far as I see currently there’s no way to turn it off, which is a problem (although I haven’t tested the latest ROOT versions). I’m not aware of a good solution to compensate the differences; maybe taking the compensation into account manually in the offset (hack) will do while waiting for better solution?

Related code can be found from;a=blob;f=graf2d/graf/src/TGaxis.cxx;h=c3172b58d47ce788c8806262f5291846dd192ee6;hb=HEAD
(search for string “mktime” located in method TGaxis::PaintAxis)

Thank you for your answer eventhough it is disappointed :frowning:

Do you have any suggestion how to compute this time offset to correct this problem? I’m not very good with time conversions, offsets and so on…
Thank you. … time-units

which root version are you using ?


thank you for the link but it does not really solve my problem.

In fact, if I run the examples given on the how-to page, I see the same bug. For instance:


TDatime da(2003,02,28,12,00,00);

ct = new TCanvas(“ct”,“Time on axis”,0,0,600,600);

ht1 = new TH1F(“ht1”,“ht1”,30000,0.,200000.);
for (Int_t i=1;i<30000;i++) {
Float_t noise = gRandom->Gaus(0,120);

ht1->GetXaxis()->SetTimeFormat("%d/%m/%y %H:%M:%S%F2000-02-28 13:00:01");

Just try it and zoom on the origin. You will see the hour does not match.
I’m using ROOT 5.34.03. Was this bug corrected in a more recent version?


Fixes have been done in 5.34-02 see … ease-notes

but you are using -03…