14 #if defined(G__WIN32) && defined(__CINT__) && !defined(__MAKECINT__)
19 gSystem->CompileMacro(
"timeonaxis3.C");
33 TString stime(time_t* t,
bool utc =
false,
bool display_time_zone =
true) {
35 if (utc) tt = gmtime(t);
36 else tt = localtime(t);
38 if (display_time_zone) strftime(buf,
sizeof(buf),
"%Y-%m-%d %H:%M:%S %Z", tt);
39 else strftime(buf,
sizeof(buf),
"%Y-%m-%d %H:%M:%S", tt);
44 TCanvas *timeonaxis3() {
47 TCanvas* c =
new TCanvas;
49 TLatex* tex1 =
new TLatex;
51 tex1->SetTextFont(102);
52 tex1->SetTextSize(0.055*f);
54 TLatex* tex3 =
new TLatex;
56 tex3->SetTextFont(102);
57 tex3->SetTextSize(0.07*f);
58 tex3->SetTextColor(kBlue+2);
60 TLatex* tex2 =
new TLatex;
62 tex2->SetTextFont(102);
63 tex2->SetTextSize(0.07*f);
64 tex2->SetTextColor(kOrange+3);
66 time_t offset[] = {0, 0, 1325376000, 1341100800};
67 time_t t[] = {1331150400, 1336417200, 0, 36000};
69 c->SetTopMargin(0); c->SetBottomMargin(0);
70 c->SetLeftMargin(0); c->SetRightMargin(0);
71 c->Divide(2, 4, -1, -1);
73 l.DrawLine(0.5, 0, 0.5, 1.);
75 for(
int i = 0; i < 4; ++i){
76 for(
int gmt = 0; gmt < 2; ++gmt){
77 const char* opt = (gmt ?
"gmt" :
"local");
78 TVirtualPad* p = c->cd(2*i + gmt + 1);
79 p->SetTopMargin(0); p->SetBottomMargin(0);
80 p->SetLeftMargin(0); p->SetRightMargin(0);
81 p->SetFillStyle(4000);
83 TGaxis* ga =
new TGaxis (.4, .25, 5., .25, t[i], t[i] + 1, 1,
"t");
84 ga->SetTimeFormat(
"TGaxis label: #color[2]{%Y-%m-%d %H:%M:%S}");
85 ga->SetLabelFont(102);
86 ga->SetLabelColor(kBlue+2);
88 ga->SetTimeOffset(offset[i], opt);
89 ga->SetLabelOffset(0.04*f);
90 ga->SetLabelSize(0.07*f);
97 TAxis a(10, 0, 1600000000);
98 a.SetTimeOffset(offset[i], opt);
99 const char* offsettimeformat = a.GetTimeFormat();
102 if (offset[i] < t[i]) {
103 sprintf(buf,
"#splitline{%s, %s}{offset: %ld, option %s}",
104 stime(t+i).Data(), stime(t+i,
true).Data(), offset[i], opt);
107 int m = (t[i] - 3600 * h) / 60 ;
108 int s = (t[i] - h * 3600 - m * 60);
109 sprintf(buf,
"#splitline{%d h %d m %d s}{offset: %s, option %s}",
110 h, m, s, stime(offset + i, gmt).Data(), opt);
112 tex1->DrawLatex(.01, .75, buf);
113 tex2->DrawLatex(.01, .50, offsettimeformat);
114 time_t t_ = t[i] + offset[i];
115 sprintf(buf,
"Expecting: #color[2]{%s}", stime(&t_, gmt,
false).Data());
116 tex3->DrawLatex(.01, .24, buf);
117 if(i > 0) l.DrawLine(0, 0.95, 1, 0.95);