Skip to content

Commit

Permalink
Implement TAxis::GetTimeOffset (root-project#13595)
Browse files Browse the repository at this point in the history
  • Loading branch information
couet authored and maksgraczyk committed Jan 12, 2024
1 parent 5645039 commit a7dcfb9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions hist/hist/inc/TAxis.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ class TAxis : public TNamed, public TAttAxis {
virtual Bool_t GetTimeDisplay() const {return fTimeDisplay;}
virtual const char *GetTimeFormat() const {return fTimeFormat.Data();}
virtual const char *GetTimeFormatOnly() const;
UInt_t GetTimeOffset();
const char *GetTitle() const override {return fTitle.Data();}
const TArrayD *GetXbins() const {return &fXbins;}
Int_t GetFirst() const;
Expand Down
20 changes: 20 additions & 0 deletions hist/hist/src/TAxis.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,26 @@ const char *TAxis::GetTimeFormatOnly() const
return timeformat.Data();
}

////////////////////////////////////////////////////////////////////////////////
/// Return the time offset in GMT.

UInt_t TAxis::GetTimeOffset() {

Int_t idF = fTimeFormat.Index("%F")+2;
if (idF<2) {
Warning("GetGMTimeOffset","Time format is not set!");
return 0;
}
TString stime=fTimeFormat(idF,19);
if (stime.Length() != 19) {
Warning("GetGMTimeOffset","Bad time format!");
return 0;
}

TDatime datime(stime.Data());
return datime.Convert(kTRUE); // Convert to unix gmt time
}

////////////////////////////////////////////////////////////////////////////////
/// Return the ticks option (see SetTicks)

Expand Down

0 comments on commit a7dcfb9

Please sign in to comment.