I have been using TAxis->setTimeFormat(#splitline{%H:%M:%S}{%m/%d/%y}%F1970-01-02 02:00:00) to set the time on the xaxis. There appear to be several things wrong with the conversion. All of the times I am plotting are epoch times. The time zone I am converting to is +13 during DST and +12 normally. First, when I use the beginning epoch time (1970-01-01 00:00:00), The conversion is 12 hours behind the actual time. Secondly, when I change the time time format offset from 1970-01-01 00:00:00 to 1970-01-02 00:00:00, the time only changes 23 hours not 24. Finally, there are other changes in the time. I have data from march and may. Somewhere in there, DST ended, so the time zone changed from +13 to +12. I would expect the times to be an hour ahead, but instead they were two hours ahead. I am guessing that sometime between march and may the time conversion went 25 hours in one day. Has anyone seen this problem before or see something that I am doing wrong?
The details about time axis on this page: root.cern.ch/drupal/content/how- … time-units
I guess you saw it.
Can you send a small macro reproducing the problem ?
have you tried to use the GMT option ?
The first thing I found is that when using the manual time offset ( %F1970-01-01 12:00:00 ), local DST is taken into account. This means that 02:00:00 doesn’t exist on the graph. I think this can be traced back to strftime() which uses local time zone information. Still thought, that doesn’t explain why I have to offset 12 hours to get gmt time.
Next, I tried the gmt option with gr1->GetXaxis()->SetTimeOffset(0,“gmt”);
The time was still 5 hours behind what epochconverter.com/ says it should be. My only guess is that that is a time zone difference (because I am located in the -5 time zone). Is this correct?
Finally, I noticed that changing the gmt offset does not work correctly. Adding 25 hours with (90000,“gmt”); offsets the time 24 hours. Offsetting the time anything less than 3600 has no effect at all, and anything over 3600 it offsets by that number - 3600.
root [0] TDatime T1(2010,01,10,00,00,00);
root [1] int i = T1.Convert();
root [2] cout<<i
1263103200(class ostream)140638169647968
root [3]
I put 1263103200 in epochconverter.com/ and the result was GMT: Sun, 10 Jan 2010 06:00:00 GMT (see attachment).
So either there are two different standards or one of the two methods does not work correctly. Could it be from the fact that root seems to use 1995 as a base for TDatime, whereas the epoch converter uses 1970?
I tried to experimentally find the right time for 1263103200 (the time root gave me for 00:00:00 January 10, 2010) :
In my example I am using TDatime as recommended in the howto about time axis, and it is working. I guess the difference comes from the fact that ROOT has a different reference date.
Ok, if I use T1.convert(true), then it is supposed the convert from gmt time (instead of local time, as it was doing before). However, the time from epochconverter.com/ is still 12 hours off… GMT: Sun, 10 Jan 2010 12:00:00 GMT
I suppose this would work IF I use the setTimeOffset(0,“gmt”) to actually use gmt time, not local time. As you showed before when you converted 1/10/2010 to a local timestamp then back to 1/10/10 again correctly, setTimeOffset(0,“gmt”), assumes all times are in local time…
I found the solution. I set the environment variable TZ in my shell to NZ (export TZ = NZ). Then I used setTimeOffset (0,“gmt”) and it set the time correctly to local south pole time (although DST at the pole is not taken into account).
It’s not defined on mine (Ubuntu 10.04) either until I export it. However, date command is different from before and after I set the variable, so it should work.