#include #include "TString.h" #include "TError.h" #include "TDatime.h" #include TString fTimeFormat="%d/%m/%y%F2023-08-16 12:02:57s0"; UInt_t GetGMTimeOffset() { 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!"); // Info("GetGMTimeOffset","String format='%s', index=%d, data='%s'",fTimeFormat.Data(),idF,stime.Data()); // return 0; TDatime datime(stime.Data()); std::time_t time = datime.Convert() // Convert to time_t local time, unixtime ,localOffset = time - std::mktime(std::gmtime(&time)) // local offset, sec ,gmt_time = time - localOffset; // GMT (UTC) unixtim Info("GetGMTimeOffset","Unix local time=%ld, time zone offset=%ld, unix GMT time=%ld",time,localOffset,gmt_time); return gmt_time; } //GetGMTimeOffset1 int TAxis_GetGMTimeOffset1() { UInt_t unix_time = GetGMTimeOffset(); Info("TAxis_GetGMTimeOffset1","String format='%s', Unix time (GMT): %u",fTimeFormat.Data(),unix_time); return 0; }