Plotting TTimeStamp gives me a crazy offset

Dear ROOTERS,

When trying to plot data requested from a database I get strange offset when plotting
For example I want to plot data for 2007-08-05 12h, using a 6 hours windows (3Hours before, 3 after)
The TimeStamp interpretation is correct for the title, but there is something strange with the TGraph (or the AXIS ?) and the line which should be at the center.

If someone can explain me the reason for these offset (which are different for data and for the line) I could solve it adding some time by hand but that’s just ugly and not what I want to do

Here is my code (Commented example) The last part is the plotting the first part the request in database

//MYSQLPP is used for the mysql interface,
//I dont show here the DB connection (not interesting and saves space) 
//Start by defining a time window 
    string evtID="Test";
    TTimeStamp evttime(1186315200); // 2007 March 5th 12h00 GMT
    TTimeStamp evttimemin(1186315200-3*3600);
    TTimeStamp evttimemax(1186315200+3*3600);
//Write an SQL request and store time and value into 2 vectors

    sql.str("");
    evttime.GetDate(0,0,&yy,&mm,&dd);
    sql << "SELECT `TimeStamp`,`Field` FROM BLS_Field_1S_";
    if (mm<10) sql << "0";
    sql <<mm;
    if (yy<2010)sql<<"0"; 
    sql <<yy-2000 << " WHERE `Timestamp` BETWEEN \""<< evttimemin.AsString("s") << "\"AND\""
      <<  evttimemax.AsString("s") <<"\" ORDER BY `Timestamp`;";
    cout <<sql.str() <<endl;
     try {
       mysqlpp::StoreQueryResult res;
       if (res=conn->query(sql.str().c_str()).store()){
	for (size_t i = 0; i < res.num_rows(); ++i) {
	 mysqlpp::DateTime dt=mysqlpp::DateTime(res[i][0]);
	 v_ts.push_back(float(time_t(dt))); // is a std::vector<float>
	 v_field.push_back(float(res[i][1])); // is a std::vector<float> 
	 }
	}
       }
     catch(mysqlpp::BadQuery e) {
       cerr << " Error making the request \n";
       cerr <<" \t Error #" << e.errnum() <<"\n";
       cerr <<" \t "<<e.what();
       cerr <<" The request was : \n";
       cerr << sql.str() << endl;
       }
    if (v_ts.size()==0) { 
      cout << evtID << "ZERO " << endl;
      cout << sql.str() << endl;
      }
//Construct a TGraph using the vector's content
    TGraph gr_field(v_ts.size(),&v_ts.front(),&v_field.front());
    TCanvas can0("plt","plot",800,600);
    gr_field.SetTitle(("Event # "+evtID + "    " +evttime.AsString("s")).c_str());
    gr_field.SetMinimum(-5000);
    gr_field.SetMaximum(+10000);
    gr_field.GetXaxis()->SetTimeDisplay(1);
    gr_field.GetXaxis()->SetRangeUser(*v_ts.begin(),*v_ts.end());
//Set Reference time to 1970 01 01 should be that for a TimeStamp isn't it ? 
    gr_field.GetXaxis()->SetTimeFormat("%H:%M %F01-01-1970 00:00:00");

    gr_field.GetXaxis()->SetTimeFormat("%H:%M");
//Draw a TLine at the event's time position 
    TLine l(evttime.GetSec(),-5000.,evttime.GetSec(),+10000);
    l.SetLineWidth(1);
    l.SetLineColor(kBlue);
    l.SetLineStyle(2);
    gr_field.SetLineColor(kRed);
    gr_field.SetMarkerStyle(1);
    gr_field.SetMarkerColor(kRed);
    gr_field.Draw("AL");
    l.Draw("SAME");
    can0.SaveAs((evtID+".png").c_str());

  exit(0);
  }

As you see the TLine is not at all at 12h
moreover the data are plotted between 10h and 16h but should be plotted between 09h and 15h

Last point my SQL request is

SELECT `TimeStamp`,`Field` FROM BLS_Field_1S_0807 WHERE `Timestamp` BETWEEN "2007-08-05 09:00:00"AND"2007-08-05 15:00:00" ORDER BY `Timestamp`;

So it is really between 09h and 15h

What’s the problem with the plotting ?

Thanks for your answers

Can you send a small example we can run. Showing the problem ?

I cannot really make the previous code smaller (database interface et al.)

But this small example can reproduce a part of the problem (I have the impression that the offset for data coming from the DB and for the TTimeStamp constructed from second are different)
This code will
Draw a small graph which as the following value
:arrow_right: +1 in a 100s window just before a reference time
:arrow_right: -1 in a 100s window just after a reference time
:arrow_right: 0 elsewhere
Moreover a blue line is also displayed at the refernce time,
Reference timestamp is set arbitrary at
Sunday, August 5th 2007, 12:00:00 (GMT)
the timestamp conversion is made using this site but it does not really matters.

What I see :
The line and the peak are at the same position but this occurs at 15h and not at 12h,
So there is somewhere an offset to add (but I don’t know why and where)

{ 
TTimeStamp evttime(1186315200);  
TTimeStamp evttimemin(1186315200-3*3600);
TTimeStamp evttimemax(1186315200+3*3600);
time_t t1(1186315200);
vector<float> v_ts;
vector<float> v_value;
//Basic sanity check in case I missed something both pass
if (evttime.GetSec()!=1186315200) cout << "There is something I don't understand" <<endl;
if (t1!=evttime.GetSec())  cout << "There is something I don't understand (2)" <<endl;
//
for (double i=evttimemin.GetSec();i<evttimemax.GetSec();i=i+6) { 
  float val=0;
  if (i> evttime.GetSec() && i<evttime.GetSec()+100) val=-1;
  if (i<evttime.GetSec() && i>evttime.GetSec()-100) val=+1;
  v_ts.push_back(i);
  v_value.push_back(val);
  }
TGraph gr(v_ts.size(),&v_ts.front(),&v_value.front());
gr.GetXaxis()->SetTimeDisplay(1);
gr.GetXaxis()->SetTimeFormat("%H:%M %F01-01-1970 00:00:00");
TLine l(evttime.GetSec(),-1.5,evttime.GetSec(),+1.5);
l.SetLineColor(kBlue);
gr.SetLineColor(kRed);
gr.SetTitle(evttime.AsString());
gr.Draw("AL");
l.Draw("SAME");

}

I guess I am missing something with the timezone

EDIT
P.S. using SetTimeOffset(0,“gmt”) still let me 1h of offset (Summer time ? )

For me that one is fine:

{
   TDatime T0(2007,8,5,10,0,0);
   int X0 = T0.Convert();
   TDatime T1(2007,8,5,12,0,0);
   int X1 = T1.Convert();
   TDatime T2(2007,8,5,14,0,0);
   int X2 = T2.Convert();

   double x[3],y[3];
   x[0] = X0; y[0] = 0;
   x[1] = X1; y[1] = 1;
   x[2] = X2; y[2] = 0;

   TGraph g(3,x,y);
   g.GetXaxis()->SetTimeDisplay(1);
   g.Draw("AL");
}

I think I found the solution after archeology in the forum and an Esoteric reading of the TTimeStamp documentation

2 small change are needed :

gr_field.GetXaxis()->SetTimeOffset(0,"gmt");

to use GMT time instead of local time

evttime.GetSec()+evttime.GetZoneOffset()

To suppress summer/winter time offset (or anything else)
With that I get the plot I want without any magic trick
Thanks anyway for the answers