diff --git a/graf/inc/TGaxis.h b/graf/inc/TGaxis.h index 852a67b140fd3107344dc61a6cceed8cfc5708d1..dbdf0e3a46e33b6fd2f393f196fe670625e56a10 100644 --- a/graf/inc/TGaxis.h +++ b/graf/inc/TGaxis.h @@ -1,4 +1,4 @@ -// @(#)root/graf:$Name: $:$Id: TGaxis.h,v 1.13 2003/04/10 09:00:20 brun Exp $ +// @(#)root/graf:$Name: $:$Id: TGaxis.h,v 1.14 2003/09/12 09:18:01 brun Exp $ // Author: Rene Brun, Olivier Couet 12/12/94 /************************************************************************* @@ -115,7 +115,7 @@ virtual const char *GetTitle() const {return fTitle.Data();} void SetTickSize(Float_t ticksize) {fTickSize = ticksize;} // *MENU* void SetGridLength(Float_t gridlength) {fGridLength = gridlength;} void SetTimeFormat(const char *tformat); - void SetTimeOffset(Double_t toffset); + void SetTimeOffset(Double_t toffset, Option_t *option="local"); virtual void SetTitle(const char *title=""); // *MENU* void SetTitleOffset(Float_t titleoffset=1) {fTitleOffset = titleoffset;} // *MENU* void SetTitleSize(Float_t titlesize) {fTitleSize = titlesize;} // *MENU* diff --git a/graf/src/TGaxis.cxx b/graf/src/TGaxis.cxx index e96652409737b90cbf367407ee5a404d56e268f8..1e570f7be7733a8707d82207b6e09e7a02de9498 100644 --- a/graf/src/TGaxis.cxx +++ b/graf/src/TGaxis.cxx @@ -1,4 +1,4 @@ -// @(#)root/graf:$Name: $:$Id: TGaxis.cxx,v 1.59 2003/09/23 14:56:50 brun Exp $ +// @(#)root/graf:$Name: $:$Id: TGaxis.cxx,v 1.60 2003/11/25 11:34:58 brun Exp $ // Author: Rene Brun, Olivier Couet 12/12/94 /************************************************************************* @@ -622,7 +622,18 @@ void TGaxis::PaintAxis(Double_t xmin, Double_t ymin, Double_t xmax, Double_t yma tp.tm_min = mi; tp.tm_sec = ss; tp.tm_isdst = -1; - timeoffset = mktime(&tp); + timeoffset = mktime(&tp); + // Add the time offset's decimal part if it is there + Int_t Ids = stringtimeoffset.Index("s"); + if (Ids >= 0) { + Float_t dp; + Int_t Lns = stringtimeoffset.Length(); + TString sdp = stringtimeoffset(Ids+1,Lns); + sscanf(sdp.Data(),"%g",&dp); + timeoffset += dp; + } + // if OptionTime = 2 gmtime will be used instead of localtime + if (stringtimeoffset.Index("GMT")) OptionTime =2; } else { Error(where, "Time offset has not the right format"); } @@ -1353,7 +1364,11 @@ L110: if (OptionTime) { timed = Wlabel + (int)(timeoffset) - rangeOffset; timelabel = (time_t)((Long_t)(timed)); - utctis = localtime(&timelabel); + if (OptionTime == 1) { + utctis = localtime(&timelabel); + } else { + utctis = gmtime(&timelabel); + } TString timeformattmp; if (timeformat.Length() < 220) timeformattmp = timeformat; else timeformattmp = "#splitline{Format}{too long}"; @@ -1935,22 +1950,43 @@ void TGaxis::SetTimeFormat(const char *tformat) } //______________________________________________________________________________ -void TGaxis::SetTimeOffset(Double_t toffset) +void TGaxis::SetTimeOffset(Double_t toffset, Option_t *option) { // Change the time offset - char sqldate[20]; + // If option = "gmt" the time offset is treated as a GMT time. + + TString opt = option; + opt.ToLower(); + + Bool_t gmt = kFALSE; + if (opt.Contains("gmt")) gmt = kTRUE; + + char tmp[20]; time_t timeoff; struct tm* utctis; - Int_t IdF = fTimeFormat.Index("%F"); if (IdF>=0) fTimeFormat.Remove(IdF); fTimeFormat.Append("%F"); - + timeoff = (time_t)((Long_t)(toffset)); - utctis = localtime(&timeoff); + if (gmt) { + utctis = gmtime(&timeoff); + } else { + utctis = localtime(&timeoff); + } + + strftime(tmp,256,"%Y-%m-%d %H:%M:%S",utctis); + fTimeFormat.Append(tmp); + + // append the decimal part of the time offset + Double_t ds = toffset-(Int_t)toffset; + if(ds!= 0) { + sprintf(tmp,"s%g",ds); + fTimeFormat.Append(tmp); + } - strftime(sqldate,256,"%Y-%m-%d %H:%M:%S",utctis); - fTimeFormat.Append(sqldate); + // If the time is GMT, stamp fTimeFormat + if (gmt) fTimeFormat.Append(" GMT"); } //______________________________________________________________________________ diff --git a/hist/inc/TAxis.h b/hist/inc/TAxis.h index 18204c2a1bea6a893de89052a2b82a74247b7ef3..5500791c0d9c5a7d1e9dbbd29cb69696676d35cf 100644 --- a/hist/inc/TAxis.h +++ b/hist/inc/TAxis.h @@ -1,4 +1,4 @@ -// @(#)root/hist:$Name: $:$Id: TAxis.h,v 1.25 2003/04/10 09:00:21 brun Exp $ +// @(#)root/hist:$Name: $:$Id: TAxis.h,v 1.26 2003/09/12 09:18:01 brun Exp $ // Author: Rene Brun 12/12/94 /************************************************************************* @@ -119,7 +119,7 @@ public: virtual void SetTicks(Option_t *option="+"); // *MENU* virtual void SetTimeDisplay(Int_t value) {fTimeDisplay = (value != 0);} // *TOGGLE* virtual void SetTimeFormat(const char *format=""); // *MENU* - virtual void SetTimeOffset(Double_t toffset); + virtual void SetTimeOffset(Double_t toffset, Option_t *option="local"); virtual void UnZoom(); // *MENU* ClassDef(TAxis,7) //Axis class diff --git a/hist/src/TAxis.cxx b/hist/src/TAxis.cxx index fa3c604062bc12ce5caba6415adddb3cef942da8..c311a732122af612126e4ed6f985c1c2a1319391 100644 --- a/hist/src/TAxis.cxx +++ b/hist/src/TAxis.cxx @@ -1,4 +1,4 @@ -// @(#)root/hist:$Name: $:$Id: TAxis.cxx,v 1.50 2003/10/06 13:40:55 brun Exp $ +// @(#)root/hist:$Name: $:$Id: TAxis.cxx,v 1.51 2003/10/08 07:55:26 brun Exp $ // Author: Rene Brun 12/12/94 /************************************************************************* @@ -936,22 +936,43 @@ void TAxis::SetTimeFormat(const char *tformat) //______________________________________________________________________________ -void TAxis::SetTimeOffset(Double_t toffset) +void TAxis::SetTimeOffset(Double_t toffset, Option_t *option) { // Change the time offset - char sqldate[20]; + // If option = "gmt" the time offset is treated as a GMT time. + + TString opt = option; + opt.ToLower(); + + Bool_t gmt = kFALSE; + if (opt.Contains("gmt")) gmt = kTRUE; + + char tmp[20]; time_t timeoff; struct tm* utctis; - Int_t IdF = fTimeFormat.Index("%F"); if (IdF>=0) fTimeFormat.Remove(IdF); fTimeFormat.Append("%F"); timeoff = (time_t)((Long_t)(toffset)); - utctis = localtime(&timeoff); + if (gmt) { + utctis = gmtime(&timeoff); + } else { + utctis = localtime(&timeoff); + } + + strftime(tmp,256,"%Y-%m-%d %H:%M:%S",utctis); + fTimeFormat.Append(tmp); + + // append the decimal part of the time offset + Double_t ds = toffset-(Int_t)toffset; + if(ds!= 0) { + sprintf(tmp,"s%g",ds); + fTimeFormat.Append(tmp); + } - strftime(sqldate,256,"%Y-%m-%d %H:%M:%S",utctis); - fTimeFormat.Append(sqldate); + // If the time is GMT, stamp fTimeFormat + if (gmt) fTimeFormat.Append(" GMT"); }