Problem with TAxis:SetTimeFormat()

Hi,

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
http://root.cern.ch/gitweb?p=root.git;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.

root.cern.ch/drupal/content/how- … time-units

which root version are you using ?

Hi,

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:

[code]{
gStyle->SetTitleH(0.08);

TDatime da(2003,02,28,12,00,00);
gStyle->SetTimeOffset(da.Convert());

ct = new TCanvas(“ct”,“Time on axis”,0,0,600,600);
ct->Divide(1,3);

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

ct->cd(1);
ht1->GetXaxis()->SetLabelSize(0.06);
ht1->GetXaxis()->SetTimeDisplay(1);
ht1->GetXaxis()->SetTimeFormat("%d/%m/%y %H:%M:%S%F2000-02-28 13:00:01");
ht1->Draw();
}[/code]

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?
Thanks,

Florent

Fixes have been done in 5.34-02 see root.cern.ch/drupal/content/root … ease-notes

but you are using -03…