SNAP Library 3.0, User Reference  2016-07-20 17:56:49
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
tm.h
Go to the documentation of this file.
1 #include "bd.h"
2 
4 // Forward
5 class TILx;
6 class TOLx;
7 class TTm;
8 
10 // Time-Units (round time to one of the buckets)
11 typedef enum {
13  tmu1Hour, tmu2Hour, tmu4Hour, tmu6Hour, tmu12Hour, tmuDay, tmuWeek, // Sunday is the start of the week
15  // wrap around time
16  // tmuWrapHour, tmuWrapDay, tmuWrapWeek, tmuWrapMonth, tmuWrapYear
17 } TTmUnit;
18 
20 // Time-Info
21 class TTmInfo{
22 private:
23  static bool InitP;
24  static TStrV UsMonthNmV;
25  static TStrV SiMonthNmV;
28  static void InitMonthNmV();
29  static void InitDayOfWeekNmV();
30  static void EnsureInit(){
31  if (!InitP){InitMonthNmV(); InitDayOfWeekNmV(); InitP=true;}}
32 public:
33  static int GetMonthN(const TStr& MonthNm, const TLoc& Loc=lUs);
34  static bool IsMonthNm(const TStr& MonthNm, const TLoc& Loc=lUs){
35  return GetMonthN(MonthNm, Loc)!=-1;}
36  static TStr GetMonthNm(const int& MonthN, const TLoc& Loc=lUs);
37  static int GetDayOfWeekN(const TStr& DayOfWeekNm, const TLoc& Loc=lUs);
38  static bool IsDayOfWeekNm(const TStr& DayOfWeekNm, const TLoc& Loc=lUs){
39  return GetDayOfWeekN(DayOfWeekNm, Loc)!=-1;}
40  static TStr GetDayOfWeekNm(const int& DayOfWeekN, const TLoc& Loc=lUs);
41  static TStr GetHmFromMins(const int& Mins);
42  static int GetTmUnitSecs(const TTmUnit& TmUnit);
43  static TStr GetTmUnitStr(const TTmUnit& TmUnit);
44  static TStr GetTmZoneDiffStr(const TStr& TmZoneStr);
45 
46  // day-of-week numbers
47  static const int SunN; static const int MonN;
48  static const int TueN; static const int WedN;
49  static const int ThuN; static const int FriN;
50  static const int SatN;
51 
52  // month numbers
53  static const int JanN; static const int FebN;
54  static const int MarN; static const int AprN;
55  static const int MayN; static const int JunN;
56  static const int JulN; static const int AugN;
57  static const int SepN; static const int OctN;
58  static const int NovN; static const int DecN;
59 
60  // time duration (msecs)
61  static uint64 GetMinMSecs(){return 60*1000;}
62  static uint64 GetHourMSecs(){return 60*60*1000;}
63  static uint64 GetDayMSecs(){return 24*60*60*1000;}
64  static uint64 GetWeekMSecs(){return 7*24*60*60*1000;}
65 };
66 
68 // Julian-Dates
70 public:
71  static int LastJulianDate; /* last day to use Julian calendar */
72  static int LastJulianDateN; /* jdn of same */
73  static int GetJulianDateN(int d, int m, int y);
74  static void GetCalendarDate(int jdn, int& dd, int& mm, int& yy);
75 };
76 
78 // Seconds-Time
79 // NOTE: Time origin is relative to time zone. Regardless of computer time
80 // zone second 0 maps to "Jan 1 1970 00:00" (so time zone information is lost)
81 class TSecTm {
82 private:
83  TUInt AbsSecs; // pretend that local time zone is UTC
84 private:
85  // functions that interact with C time functions (time.h)
86  static bool GetTmSec(const int& YearN, const int& MonthN, const int& DayN,
87  const int& HourN, const int& MinN, const int& SecN, uint& AbsSec);
88  static bool GetTmSec(struct tm& Tm, uint& AbsSec);
89  static bool GetTmStruct(const uint& AbsSec, struct tm& Tm);
90  static time_t MkGmTime(struct tm *t); // implementation of _mkgmtime
91 public:
92  TSecTm(): AbsSecs(TUInt::Mx){}
93  explicit TSecTm(const uint& _AbsSecs): AbsSecs(_AbsSecs){}
94  operator uint() const {return AbsSecs.Val;}
95  TSecTm(const TSecTm& SecTm): AbsSecs(SecTm.AbsSecs){}
96  TSecTm(const int& YearN, const int& MonthN, const int& DayN,
97  const int& HourN=0, const int& MinN=0, const int& SecN=0);
98  TSecTm(const TTm& Tm);
99  explicit TSecTm(const PXmlTok& XmlTok);
100  PXmlTok GetXmlTok() const;
101  TSecTm(TSIn& SIn): AbsSecs(SIn){}
102  void Load(TSIn& SIn){AbsSecs.Load(SIn);}
103  void Save(TSOut& SOut) const {AbsSecs.Save(SOut);}
104 
105  TSecTm& operator=(const TSecTm& SecTm){
106  AbsSecs=SecTm.AbsSecs; return *this;}
107  TSecTm& operator=(const uint& _AbsSecs){
108  AbsSecs=_AbsSecs; return *this;}
109  TSecTm& operator+=(const uint& Secs){
110  IAssert(IsDef()); AbsSecs()+=Secs; return *this;}
111  TSecTm& operator-=(const uint& Secs){
112  IAssert(IsDef()); AbsSecs()-=Secs; return *this;}
113  bool operator==(const TSecTm& SecTm) const {
114  return AbsSecs==SecTm.AbsSecs;}
115  bool operator<(const TSecTm& SecTm) const {
116  IAssert(IsDef()&&SecTm.IsDef()); return AbsSecs<SecTm.AbsSecs;}
117  int GetMemUsed() const {return AbsSecs.GetMemUsed();}
118 
119  int GetPrimHashCd() const {return AbsSecs.GetPrimHashCd();}
120  int GetSecHashCd() const {return AbsSecs.GetSecHashCd();}
121 
122  // definition
123  bool IsDef() const {return uint(AbsSecs)!=TUInt::Mx;}
125 
126  // string retrieval
127  TStr GetStr(const TLoc& Loc=lUs) const;
128  TStr GetStr(const TTmUnit& TmUnit) const;
129  TStr GetDtStr(const TLoc& Loc=lUs) const;
130  TStr GetDtMdyStr() const;
131  TStr GetDtYmdStr() const;
132  TStr GetYmdTmStr() const; // returns "y-m-d h:m:s"
133  TStr GetYmdTmStr2() const; // returns "y-m-d-h:m:s"
134  TStr GetTmStr() const;
135  TStr GetTmMinStr() const;
136  TStr GetDtTmSortStr() const;
137  TStr GetDtTmSortFNmStr() const;
138 
139  // component retrieval
140  int GetYearN() const;
141  int GetMonthN() const;
142  TStr GetMonthNm(const TLoc& Loc=lUs) const;
143  int GetDayN() const;
144  int GetDayOfWeekN() const;
145  TStr GetDayOfWeekNm(const TLoc& Loc=lUs) const;
146  int GetHourN() const;
147  int GetMinN() const;
148  int GetSecN() const;
149  void GetComps(int& Year, int& Month, int& Day, int& Hour, int& Min, int& Sec) const;
150  uint GetAbsSecs() const {return AbsSecs();}
151  TSecTm Round(const TTmUnit& TmUnit) const;
152  uint GetInUnits(const TTmUnit& TmUnit) const;
153  TStr GetDayPart() const;
154 
155  // additions/substractions
156  TSecTm& AddSecs(const int& Secs){
157  IAssert(IsDef()); AbsSecs.Val+=uint(Secs); return *this;}
158  TSecTm& SubSecs(const int& Secs){
159  IAssert(IsDef() && uint(Secs) < AbsSecs); AbsSecs.Val-=uint(Secs); return *this;}
160  TSecTm& AddMins(const int& Mins){
161  IAssert(IsDef()); AbsSecs.Val+=uint(Mins*60); return *this;}
162  TSecTm& SubMins(const int& Mins){
163  IAssert(IsDef() && uint(Mins*60) < AbsSecs); AbsSecs.Val-=uint(Mins*60); return *this;}
164  TSecTm& AddHours(const int& Hours){
165  IAssert(IsDef()); AbsSecs.Val+=uint(Hours*3600); return *this;}
166  TSecTm& SubHours(const int& Hours){
167  IAssert(IsDef() && uint(Hours*3600) < AbsSecs); AbsSecs.Val-=uint(Hours*3600); return *this;}
168  TSecTm& AddDays(const int& Days){
169  IAssert(IsDef()); AbsSecs.Val+=uint(Days*24*3600); return *this;}
170  TSecTm& SubDays(const int& Days){
171  IAssert(IsDef() && uint(Days*24*3600) < AbsSecs); AbsSecs.Val-=uint(Days*24*3600); return *this;}
172  TSecTm& AddWeeks(const int& Weeks){
173  IAssert(IsDef()); AbsSecs.Val+=uint(Weeks*7*24*3600); return *this;}
174  TSecTm& SubWeeks(const int& Weeks){
175  IAssert(IsDef() && uint(Weeks*7*24*3600) < AbsSecs); AbsSecs.Val-=uint(Weeks*7*24*3600); return *this;}
176  static uint GetDSecs(const TSecTm& SecTm1, const TSecTm& SecTm2);
177  /*friend TSecTm operator+(const TSecTm& SecTm, const uint& Secs){
178  return TSecTm(SecTm)+=Secs;}
179  friend TSecTm operator-(const TSecTm& SecTm, const uint& Secs){
180  return TSecTm(SecTm)-=Secs;}
181  friend TSecTm operator+(const TSecTm& SecTm1, const TSecTm& SecTm2){
182  return TSecTm(SecTm1)+=SecTm2.AbsSecs;}
183  friend TSecTm operator-(const TSecTm& SecTm1, const TSecTm& SecTm2){
184  return TSecTm(SecTm1)-=SecTm2.AbsSecs;}*/
185 
186  // time construction
187  static TSecTm GetZeroTm(){return TSecTm(0).AddHours(23);}
188  static TSecTm GetZeroWeekTm();
189  static TSecTm GetCurTm();
190  static TSecTm GetCurDtTm(){return GetDtTm(GetCurTm());}
191  static TSecTm GetDtTmFromHmsStr(const TStr& HmsStr);
192  static TSecTm GetDtTmFromMdyStr(const TStr& MdyStr);
193  static TSecTm GetDtTmFromDmyStr(const TStr& DmyStr);
194  static TSecTm GetDtTmFromMdyHmsPmStr(const TStr& MdyHmsPmStr,
195  const char& DateSepCh='/', const char& TimeSepCh=':');
196  static TSecTm GetDtTmFromYmdHmsStr(const TStr& YmdHmsPmStr,
197  const char& DateSepCh='-', const char& TimeSepCh=':');
198  static TSecTm GetDtTmFromStr(const TChA& YmdHmsPmStr, const int& YearId=0, const int& MonId=1,
199  const int& DayId=2, const int& HourId=3, const int& MinId=4, const int& SecId=5);
200  static TSecTm GetDtTm(const int& YearN, const int& MonthN, const int& DayN);
201  static TSecTm GetDtTm(const TSecTm& Tm);
202 
203  // text load/save
204  static TSecTm LoadTxt(TILx& Lx);
205  void SaveTxt(TOLx& Lx) const;
206 };
210 
212 // Time
213 class TTm{
214 private:
217 public:
218  TTm():
219  Year(-1), Month(-1), Day(-1), DayOfWeek(-1),
220  Hour(-1), Min(-1), Sec(-1), MSec(-1){}
221  TTm(const TTm& Tm):
222  Year(Tm.Year), Month(Tm.Month), Day(Tm.Day), DayOfWeek(Tm.DayOfWeek),
223  Hour(Tm.Hour), Min(Tm.Min), Sec(Tm.Sec), MSec(Tm.MSec){}
225  const int& _Year, const int& _Month, const int& _Day, const int& _DayOfWeek=-1,
226  const int& _Hour=0, const int& _Min=0, const int& _Sec=0, const int& _MSec=0):
227  Year(_Year), Month(_Month), Day(_Day), DayOfWeek(_DayOfWeek),
228  Hour(_Hour), Min(_Min), Sec(_Sec), MSec(_MSec){}
229  TTm(const TSecTm& SecTm):
230  Year(SecTm.GetYearN()), Month(SecTm.GetMonthN()), Day(SecTm.GetDayN()),
231  DayOfWeek(SecTm.GetDayOfWeekN()), Hour(SecTm.GetHourN()),
232  Min(SecTm.GetMinN()), Sec(SecTm.GetSecN()), MSec(0){}
233  ~TTm(){}
234  TTm(TSIn& SIn):
235  Year(SIn), Month(SIn), Day(SIn), DayOfWeek(SIn),
236  Hour(SIn), Min(SIn), Sec(SIn), MSec(SIn){}
237  void Save(TSOut& SOut) const {
238  Year.Save(SOut); Month.Save(SOut); Day.Save(SOut); DayOfWeek.Save(SOut);
239  Hour.Save(SOut); Min.Save(SOut); Sec.Save(SOut); MSec.Save(SOut);}
240 
241  TTm& operator=(const TTm& Tm){
242  Year=Tm.Year; Month=Tm.Month; Day=Tm.Day; DayOfWeek=Tm.DayOfWeek;
243  Hour=Tm.Hour; Min=Tm.Min; Sec=Tm.Sec; MSec=Tm.MSec;
244  return *this;}
245  bool operator==(const TTm& Tm) const {
246  return
247  (Year==Tm.Year)&&(Month==Tm.Month)&&(Day==Tm.Day)&&
248  (Hour==Tm.Hour)&&(Min==Tm.Min)&&(Sec==Tm.Sec)&&(MSec==Tm.MSec);}
249  bool operator<(const TTm& Tm) const {
250  return
251  (Year<Tm.Year)||
252  ((Year==Tm.Year)&&(Month<Tm.Month))||
253  ((Year==Tm.Year)&&(Month==Tm.Month)&&(Day<Tm.Day))||
254  (((Year==Tm.Year)&&(Month==Tm.Month)&&(Day==Tm.Day))&&(
255  (Hour<Tm.Hour)||
256  ((Hour==Tm.Hour)&&(Min<Tm.Min))||
257  ((Hour==Tm.Hour)&&(Min==Tm.Min)&&(Sec<Tm.Sec))||
258  ((Hour==Tm.Hour)&&(Min==Tm.Min)&&(Sec==Tm.Sec)&&(MSec<Tm.MSec))));} // saxo
259  int GetMemUsed() const {return sizeof(TTm);}
260 
261  int GetPrimHashCd() const {return Year*Month*Day+Hour*Min*Sec*MSec;}
262  int GetSecHashCd() const {return Year*Month*Day;}
263 
264  // defined
265  bool IsDef() const {
266  return (Year!=-1)&&(Month!=-1)&&(Day!=-1)&&
267  (Hour!=-1)&&(Min!=-1)&&(Sec!=-1)&&(MSec!=-1);}
268  void Undef(){
269  Year=-1; Month=-1; Day=-1; DayOfWeek=-1;
270  Hour=-1; Min=-1; Sec=-1; MSec=-1;}
271  // check if time is defined
272  bool IsTimeDef() const { return !(Hour==0 && Min==0 && Sec==0 && MSec==0); }
273 
274  // get components
275  int GetYear() const {return Year;}
276  int GetMonth() const {return Month;}
278  int GetDay() const {return Day;}
279  int GetDayOfWeek() const {return DayOfWeek;}
281  int GetHour() const {return Hour;}
282  int GetMin() const {return Min;}
283  int GetSec() const {return Sec;}
284  int GetMSec() const {return MSec;}
285 
286  // time string formats
287  TStr GetStr(const bool& MSecP=true) const;
288  TStr GetYMDDashStr() const;
289  TStr GetHMSTColonDotStr(const bool& FullP=false, const bool& MSecP=true) const;
290  TStr GetWebLogDateStr() const {return GetYMDDashStr();}
291  TStr GetWebLogTimeStr() const {return GetHMSTColonDotStr(false);}
292  TStr GetWebLogDateTimeStr(const bool& FullP=false, const TStr& DateTimeSepCh=" ", const bool& MSecP=true) const {
293  return GetYMDDashStr()+DateTimeSepCh+GetHMSTColonDotStr(FullP, MSecP);}
294  TStr GetIdStr() const;
295  TSecTm GetSecTm() const {
296  return TSecTm(Year, Month, Day, Hour, Min, Sec);}
297 
298  // calculation
299  void AddTime(const int& Hours, const int& Mins=0, const int& Secs=0, const int& MSecs=0);
300  void AddDays(const int& Days){AddTime(Days*24);}
301  void SubTime(const int& Hours, const int& Mins=0, const int& Secs=0, const int& MSecs=0);
302  void SubDays(const int& Days){SubTime(Days*24);}
303 
304  // static functions
305  static TTm GetCurUniTm();
306  static TTm GetUniqueCurUniTm();
307  static TTm GetUniqueCurUniTm(const int& UniqueSpaces, const int& UniqueSpaceN);
308  static TTm GetCurLocTm();
309  static uint64 GetCurUniMSecs();
310  static uint64 GetCurLocMSecs();
311  static uint64 GetMSecsFromTm(const TTm& Tm);
312  static TTm GetTmFromMSecs(const uint64& MSecs);
313  static uint GetMSecsFromOsStart();
314  static uint64 GetPerfTimerFq();
315  static uint64 GetPerfTimerTicks();
316  static void GetDiff(const TTm& Tm1, const TTm& Tm2, int& Days,
317  int& Hours, int& Mins, int& Secs, int& MSecs);
318  static uint64 GetDiffMSecs(const TTm& Tm1, const TTm& Tm2);
319  static uint64 GetDiffSecs(const TTm& Tm1, const TTm& Tm2){
320  return GetDiffMSecs(Tm1, Tm2)/uint64(1000);}
321  static uint64 GetDiffMins(const TTm& Tm1, const TTm& Tm2){
322  return GetDiffMSecs(Tm1, Tm2)/uint64(1000*60);}
323  static uint64 GetDiffHrs(const TTm& Tm1, const TTm& Tm2){
324  return GetDiffMSecs(Tm1, Tm2)/uint64(1000*60*60);}
325  static uint64 GetDiffDays(const TTm& Tm1, const TTm& Tm2){
326  return GetDiffMSecs(Tm1, Tm2)/uint64(1000*60*60*24);}
327  static TTm GetLocTmFromUniTm(const TTm& Tm);
328  static TTm GetUniTmFromLocTm(const TTm& Tm);
329  static TTm GetTmFromWebLogTimeStr(const TStr& TimeStr,
330  const char TimeSepCh=':', const char MSecSepCh='.');
331  static TTm GetTmFromWebLogDateTimeStr(const TStr& DateTimeStr,
332  const char DateSepCh='-', const char TimeSepCh=':',
333  const char MSecSepCh='.', const char DateTimeSepCh=' ');
334  static TTm GetTmFromIdStr(const TStr& IdStr);
335 
336  // get unix timestamp
337  static uint GetDateTimeInt(const int& Year = 0, const int& Month = 0,
338  const int& Day = 1, const int& Hour = 0, const int& Min = 0,
339  const int& Sec = 0);
340  static uint GetDateIntFromTm(const TTm& Tm);
341  static uint GetMonthIntFromTm(const TTm& Tm);
342  static uint GetYearIntFromTm(const TTm& Tm);
343  static uint GetDateTimeIntFromTm(const TTm& Tm);
344  static TTm GetTmFromDateTimeInt(const uint& DateTimeInt);
345  static TSecTm GetSecTmFromDateTimeInt(const uint& DateTimeInt);
346 };
347 typedef TVec<TTm> TTmV;
352 
354 // Execution-Time
355 class TExeTm{
356 private:
357  int LastTick;
358 public:
359  TExeTm(): LastTick(0) { Tick(); }
360  TExeTm(const TExeTm& Tm): LastTick(Tm.LastTick) { }
361  TExeTm& operator=(const TExeTm& Tm){
362  LastTick=Tm.LastTick; return *this;}
363 
364  void Tick(){LastTick=(int)clock();}
365  int GetTime() const {return int(clock()-LastTick);}
366  double GetSecs() const {return double(clock()-LastTick)/double(CLOCKS_PER_SEC);}
367  int GetSecInt() { return TFlt::Round(GetSecs()); }
368  const char* GetStr() const {return GetTmStr();}
369  TStr GetStr2() const {return GetTmStr();}
370  const char* GetTmStr() const { static char TmStr[32];
371  if (GetSecs() < 60) { sprintf(TmStr, "%.2fs", GetSecs()); }
372  else if (GetSecs() < 3600) { sprintf(TmStr, "%02dm%02ds", int(GetSecs())/60, int(GetSecs())%60); }
373  else { sprintf(TmStr, "%02dh%02dm", int(GetSecs())/3600, (int(GetSecs())%3600)/60); } return TmStr; }
374  static char* GetCurTm(){ static TStr TmStr; TmStr=TSecTm::GetCurTm().GetTmStr(); return TmStr.CStr(); }
375 };
376 
378 // Time-Stop-Watch
380 private:
381  int TmSoFar;
382  bool RunningP;
384 public:
385  TTmStopWatch(const bool& Start = false): TmSoFar(0), RunningP(Start) { }
386 
387  void Start() { if (!RunningP) { RunningP = true; ExeTm.Tick(); } }
388  void Stop() { if (RunningP) { RunningP = false; TmSoFar += ExeTm.GetTime(); } }
389  void Reset(const bool& Start) { TmSoFar = 0; RunningP = Start; ExeTm.Tick(); }
390 
391  int GetTime() const { return TmSoFar + (RunningP ? ExeTm.GetTime() : 0); }
392  double GetSec() const { return double(GetTime()) / double(CLOCKS_PER_SEC); }
393  int GetSecInt() const { return TFlt::Round(GetSec()); }
394  double GetMSec() const { return double(GetTime()) / double(CLOCKS_PER_SEC/1000); }
395  int GetMSecInt() const { return TFlt::Round(GetMSec()); }
396 };
397 
399 // Time-Profiler - poor-man's profiler
401 private:
402  TInt MxNmLen;
404 
405 public:
407  static PTmProfiler New() { return new TTmProfiler; }
408 
409  int AddTimer(const TStr& TimerNm);
410  int GetTimerId(const TStr& TimerNm) const { return TimerH.GetKeyId(TimerNm); }
411  TStr GetTimerNm(const int& TimerId) const { return TimerH.GetKey(TimerId); }
412  int GetTimers() const { return TimerH.Len(); }
413  int GetTimerIdFFirst() const { return TimerH.FFirstKeyId(); }
414  bool GetTimerIdFNext(int& TimerId) const { return TimerH.FNextKeyId(TimerId); }
415  // starts counting
416  void StartTimer(const TStr& TimerNm) { TimerH.GetDat(TimerNm).Start(); }
417  void StartTimer(const int& TimerId) { TimerH[TimerId].Start(); }
418  // stops counting
419  void StopTimer(const TStr& TimerNm) { TimerH.GetDat(TimerNm).Stop(); }
420  void StopTimer(const int& TimerId) { TimerH[TimerId].Stop(); }
421  // reset
422  void ResetAll();
423  void ResetTimer(const TStr& TimerNm) { TimerH.GetDat(TimerNm).Reset(false); }
424  void ResetTimer(const int& TimerId) { TimerH[TimerId].Reset(false); }
425  // report
426  double GetTimerSumSec() const;
427  double GetTimerSec(const int& TimerId) const;
428  void PrintReport(const TStr& ProfileNm = "") const;
429 };
430 
432 // Timer
433 class TTmTimer {
434 private:
435  int MxMSecs;
437 
439 public:
440  TTmTimer(const int& _MxMSecs): MxMSecs(_MxMSecs), StopWatch(true) { }
441 
442  // restarts the timer from 0
443  void Restart() { StopWatch.Reset(true); }
444  // returns true if the time has ran out
445  bool IsTimeUp() const { return (StopWatch.GetMSecInt() > MxMSecs); }
446 };
Definition: ds.h:345
#define IAssert(Cond)
Definition: bd.h:262
void GetComps(int &Year, int &Month, int &Day, int &Hour, int &Min, int &Sec) const
Definition: tm.cpp:614
int GetMSecInt() const
Definition: tm.h:395
void Start()
Definition: tm.h:387
int GetMin() const
Definition: tm.h:282
TStr GetWebLogDateStr() const
Definition: tm.h:290
static TStrV UsMonthNmV
Definition: tm.h:24
TStr GetYmdTmStr2() const
Definition: tm.cpp:514
TExeTm(const TExeTm &Tm)
Definition: tm.h:360
static TStrV SiDayOfWeekNmV
Definition: tm.h:27
TInt MSec
Definition: tm.h:216
bool GetTimerIdFNext(int &TimerId) const
Definition: tm.h:414
int GetMinN() const
Definition: tm.cpp:602
int GetMemUsed() const
Definition: tm.h:259
static TSecTm GetDtTmFromStr(const TChA &YmdHmsPmStr, const int &YearId=0, const int &MonId=1, const int &DayId=2, const int &HourId=3, const int &MinId=4, const int &SecId=5)
Definition: tm.cpp:915
static char * GetCurTm()
Definition: tm.h:374
int GetMSec() const
Definition: tm.h:284
static void GetCalendarDate(int jdn, int &dd, int &mm, int &yy)
Definition: tm.cpp:327
TSecTm & AddDays(const int &Days)
Definition: tm.h:168
TPair< TTm, TStr > TTmStrPr
Definition: tm.h:348
static TSecTm GetDtTmFromYmdHmsStr(const TStr &YmdHmsPmStr, const char &DateSepCh='-', const char &TimeSepCh=':')
Definition: tm.cpp:859
void Restart()
Definition: tm.h:443
static uint64 GetDayMSecs()
Definition: tm.h:63
static uint64 GetCurLocMSecs()
Definition: tm.cpp:1068
static void InitDayOfWeekNmV()
Definition: tm.cpp:24
TStr GetWebLogDateTimeStr(const bool &FullP=false, const TStr &DateTimeSepCh=" ", const bool &MSecP=true) const
Definition: tm.h:292
Definition: tm.h:69
static uint64 GetDiffMins(const TTm &Tm1, const TTm &Tm2)
Definition: tm.h:321
Definition: tm.h:355
static uint GetDateIntFromTm(const TTm &Tm)
Definition: tm.cpp:1242
TStr GetStr2() const
Definition: tm.h:369
TExeTm ExeTm
Definition: tm.h:383
int GetMonth() const
Definition: tm.h:276
TSecTm & SubSecs(const int &Secs)
Definition: tm.h:158
static void GetDiff(const TTm &Tm1, const TTm &Tm2, int &Days, int &Hours, int &Mins, int &Secs, int &MSecs)
Definition: tm.cpp:1092
static int GetJulianDateN(int d, int m, int y)
Definition: tm.cpp:303
static void EnsureInit()
Definition: tm.h:30
static void InitMonthNmV()
Definition: tm.cpp:9
Definition: tm.h:13
Definition: tm.h:13
int GetYearN() const
Definition: tm.cpp:560
TTmStopWatch(const bool &Start=false)
Definition: tm.h:385
bool IsDef() const
Definition: tm.h:123
Definition: tm.h:12
static const uint Mx
Definition: dt.h:1154
void Save(TSOut &SOut) const
Definition: dt.h:1060
TStr GetYMDDashStr() const
Definition: tm.cpp:975
static TTm GetUniTmFromLocTm(const TTm &Tm)
Definition: tm.cpp:1121
static TSecTm GetDtTmFromHmsStr(const TStr &HmsStr)
Definition: tm.cpp:712
static int LastJulianDate
Definition: tm.h:71
unsigned int uint
Definition: bd.h:11
static uint64 GetCurUniMSecs()
Definition: tm.cpp:1064
int GetDayOfWeekN() const
Definition: tm.cpp:584
double GetMSec() const
Definition: tm.h:394
Definition: tm.h:12
void Save(TSOut &SOut) const
Definition: tm.h:237
TInt Day
Definition: tm.h:215
static bool IsDayOfWeekNm(const TStr &DayOfWeekNm, const TLoc &Loc=lUs)
Definition: tm.h:38
void SubDays(const int &Days)
Definition: tm.h:302
TTm(const int &_Year, const int &_Month, const int &_Day, const int &_DayOfWeek=-1, const int &_Hour=0, const int &_Min=0, const int &_Sec=0, const int &_MSec=0)
Definition: tm.h:224
Definition: tm.h:14
TSecTm & AddMins(const int &Mins)
Definition: tm.h:160
static int GetTmUnitSecs(const TTmUnit &TmUnit)
Definition: tm.cpp:85
static TTm GetCurUniTm()
Definition: tm.cpp:1029
TExeTm()
Definition: tm.h:359
void Load(TSIn &SIn)
Definition: tm.h:102
bool operator==(const TTm &Tm) const
Definition: tm.h:245
int GetSecHashCd() const
Definition: tm.h:120
static uint64 GetHourMSecs()
Definition: tm.h:62
PXmlTok GetXmlTok() const
Definition: tm.cpp:446
static uint GetDateTimeIntFromTm(const TTm &Tm)
Definition: tm.cpp:1254
int GetTime() const
Definition: tm.h:391
TStr GetDtYmdStr() const
Definition: tm.cpp:502
Definition: tm.h:13
int LastTick
Definition: tm.h:357
TSecTm & SubMins(const int &Mins)
Definition: tm.h:162
static const int JanN
Definition: tm.h:53
bool IsTimeUp() const
Definition: tm.h:445
uint GetInUnits(const TTmUnit &TmUnit) const
Definition: tm.cpp:650
void SaveTxt(TOLx &Lx) const
Definition: tm.cpp:954
bool operator==(const TSecTm &SecTm) const
Definition: tm.h:113
Definition: tm.h:13
int GetTime() const
Definition: tm.h:365
int GetTimers() const
Definition: tm.h:412
static const int OctN
Definition: tm.h:57
TStr GetTmMinStr() const
Definition: tm.cpp:530
static const int JulN
Definition: tm.h:56
static uint GetDateTimeInt(const int &Year=0, const int &Month=0, const int &Day=1, const int &Hour=0, const int &Min=0, const int &Sec=0)
Definition: tm.cpp:1236
bool RunningP
Definition: tm.h:382
static uint64 GetDiffMSecs(const TTm &Tm1, const TTm &Tm2)
Definition: tm.cpp:1107
TSecTm & AddWeeks(const int &Weeks)
Definition: tm.h:172
static TTm GetTmFromDateTimeInt(const uint &DateTimeInt)
Definition: tm.cpp:1260
void StopTimer(const int &TimerId)
Definition: tm.h:420
static TTm GetTmFromWebLogDateTimeStr(const TStr &DateTimeStr, const char DateSepCh='-', const char TimeSepCh=':', const char MSecSepCh='.', const char DateTimeSepCh=' ')
Definition: tm.cpp:1159
~TTm()
Definition: tm.h:233
int MxMSecs
Definition: tm.h:435
TInt Sec
Definition: tm.h:216
bool IsTimeDef() const
Definition: tm.h:272
TStr GetDtTmSortFNmStr() const
Definition: tm.cpp:550
int GetHour() const
Definition: tm.h:281
int GetMonthN() const
Definition: tm.cpp:566
TInt Min
Definition: tm.h:216
static TSecTm GetDtTmFromDmyStr(const TStr &DmyStr)
Definition: tm.cpp:766
TStr GetIdStr() const
Definition: tm.cpp:996
Definition: tm.h:12
Definition: tm.h:12
bool operator<(const TTm &Tm) const
Definition: tm.h:249
static TSecTm GetSecTmFromDateTimeInt(const uint &DateTimeInt)
Definition: tm.cpp:1265
Definition: tm.h:21
Definition: tm.h:13
TTmTimer(const int &_MxMSecs)
Definition: tm.h:440
TSecTm & SubDays(const int &Days)
Definition: tm.h:170
static const int NovN
Definition: tm.h:58
Definition: fl.h:58
void Save(TSOut &SOut) const
Definition: tm.h:103
Definition: tm.h:14
bool operator<(const TSecTm &SecTm) const
Definition: tm.h:115
static const int AprN
Definition: tm.h:54
static TStr GetDayOfWeekNm(const int &DayOfWeekN, const TLoc &Loc=lUs)
Definition: tm.cpp:71
static TSecTm GetDtTmFromMdyStr(const TStr &MdyStr)
Definition: tm.cpp:738
Definition: bd.h:63
static const int ThuN
Definition: tm.h:49
#define ClassTP(TNm, PNm)
Definition: bd.h:126
TSecTm()
Definition: tm.h:92
const char * GetTmStr() const
Definition: tm.h:370
UndefDefaultCopyAssign(TTmTimer)
static bool InitP
Definition: tm.h:23
TSecTm(TSIn &SIn)
Definition: tm.h:101
void Save(TSOut &SOut) const
Definition: dt.h:1162
int GetYear() const
Definition: tm.h:275
static uint GetYearIntFromTm(const TTm &Tm)
Definition: tm.cpp:1250
TSecTm & operator+=(const uint &Secs)
Definition: tm.h:109
TSecTm & operator=(const TSecTm &SecTm)
Definition: tm.h:105
static bool GetTmSec(const int &YearN, const int &MonthN, const int &DayN, const int &HourN, const int &MinN, const int &SecN, uint &AbsSec)
Definition: tm.cpp:363
void Stop()
Definition: tm.h:388
static TSecTm GetCurDtTm()
Definition: tm.h:190
TInt Hour
Definition: tm.h:216
static TTm GetTmFromIdStr(const TStr &IdStr)
Definition: tm.cpp:1215
TVec< TTm > TTmV
Definition: tm.h:347
TExeTm & operator=(const TExeTm &Tm)
Definition: tm.h:361
int GetTimerId(const TStr &TimerNm) const
Definition: tm.h:410
static const int MayN
Definition: tm.h:55
TTm()
Definition: tm.h:218
TSecTm & operator-=(const uint &Secs)
Definition: tm.h:111
TInt Month
Definition: tm.h:215
unsigned long long uint64
Definition: bd.h:38
TLoc
Definition: bd.h:63
int GetDay() const
Definition: tm.h:278
int GetTimerIdFFirst() const
Definition: tm.h:413
Definition: lx.h:129
TSecTm(const uint &_AbsSecs)
Definition: tm.h:93
TSecTm & operator=(const uint &_AbsSecs)
Definition: tm.h:107
TKeyDat< TSecTm, TStr > TSecTmStrKd
Definition: tm.h:208
uint GetAbsSecs() const
Definition: tm.h:150
int GetSecInt()
Definition: tm.h:367
int GetSecN() const
Definition: tm.cpp:608
Definition: lx.h:251
static const int SepN
Definition: tm.h:57
TTm(const TTm &Tm)
Definition: tm.h:221
int GetHourN() const
Definition: tm.cpp:596
bool IsDef() const
Definition: tm.h:265
int GetDayN() const
Definition: tm.cpp:578
Definition: tm.h:433
static uint GetMSecsFromOsStart()
Definition: tm.cpp:1080
void Load(TSIn &SIn)
Definition: dt.h:1161
static TStrV UsDayOfWeekNmV
Definition: tm.h:26
TSecTm GetSecTm() const
Definition: tm.h:295
static time_t MkGmTime(struct tm *t)
Definition: tm.cpp:380
int GetMemUsed() const
Definition: tm.h:117
Definition: tm.h:14
static uint64 GetDiffHrs(const TTm &Tm1, const TTm &Tm2)
Definition: tm.h:323
static uint64 GetPerfTimerTicks()
Definition: tm.cpp:1088
static TTm GetCurLocTm()
Definition: tm.cpp:1060
static uint64 GetDiffSecs(const TTm &Tm1, const TTm &Tm2)
Definition: tm.h:319
void Tick()
Definition: tm.h:364
static const int DecN
Definition: tm.h:58
TStr GetDayOfWeekNm(const TLoc &Loc=lUs) const
Definition: tm.cpp:590
int GetMemUsed() const
Definition: dt.h:1182
TInt Year
Definition: tm.h:215
TTm(const TSecTm &SecTm)
Definition: tm.h:229
Definition: fl.h:128
TVec< TTmStrPr > TTmStrPrV
Definition: tm.h:350
Definition: tm.h:213
void StopTimer(const TStr &TimerNm)
Definition: tm.h:419
TSecTm(const TSecTm &SecTm)
Definition: tm.h:95
void StartTimer(const TStr &TimerNm)
Definition: tm.h:416
TVec< TSecTm > TSecTmV
Definition: tm.h:207
static int Round(const double &Flt)
Definition: dt.h:1339
Definition: dt.h:1044
static uint64 GetWeekMSecs()
Definition: tm.h:64
TTm(TSIn &SIn)
Definition: tm.h:234
TSecTm & AddSecs(const int &Secs)
Definition: tm.h:156
Definition: dt.h:201
TTm & operator=(const TTm &Tm)
Definition: tm.h:241
Definition: dt.h:1149
static TStr GetMonthNm(const int &MonthN, const TLoc &Loc=lUs)
Definition: tm.cpp:50
TUInt AbsSecs
Definition: tm.h:83
static TSecTm GetZeroWeekTm()
Definition: tm.cpp:690
Definition: tm.h:81
static TSecTm GetDtTm(const int &YearN, const int &MonthN, const int &DayN)
Definition: tm.cpp:938
Definition: ds.h:32
static TStrV SiMonthNmV
Definition: tm.h:25
Definition: tm.h:12
static TStr GetTmZoneDiffStr(const TStr &TmZoneStr)
Definition: tm.cpp:131
static TSecTm LoadTxt(TILx &Lx)
Definition: tm.cpp:950
TVec< TSecTmStrKd > TSecTmStrKdV
Definition: tm.h:209
static PTmProfiler New()
Definition: tm.h:407
TStr GetTimerNm(const int &TimerId) const
Definition: tm.h:411
static TStr GetTmUnitStr(const TTmUnit &TmUnit)
Definition: tm.cpp:108
int GetSec() const
Definition: tm.h:283
TStr GetDayOfWeekNm() const
Definition: tm.h:280
TStr GetDtTmSortStr() const
Definition: tm.cpp:540
static uint GetMonthIntFromTm(const TTm &Tm)
Definition: tm.cpp:1246
TStr GetMonthNm(const TLoc &Loc=lUs) const
Definition: tm.cpp:572
Definition: dt.h:412
static TTm GetUniqueCurUniTm()
Definition: tm.cpp:1033
static TTm GetTmFromWebLogTimeStr(const TStr &TimeStr, const char TimeSepCh=':', const char MSecSepCh='.')
Definition: tm.cpp:1125
TStr GetStr(const TLoc &Loc=lUs) const
Definition: tm.cpp:457
static const int FriN
Definition: tm.h:49
static bool IsMonthNm(const TStr &MonthNm, const TLoc &Loc=lUs)
Definition: tm.h:34
static const int WedN
Definition: tm.h:48
Definition: hash.h:88
static int GetMonthN(const TStr &MonthNm, const TLoc &Loc=lUs)
Definition: tm.cpp:39
int TmSoFar
Definition: tm.h:381
TStr GetDtStr(const TLoc &Loc=lUs) const
Definition: tm.cpp:484
static const int AugN
Definition: tm.h:56
void AddDays(const int &Days)
Definition: tm.h:300
double GetSecs() const
Definition: tm.h:366
void ResetTimer(const TStr &TimerNm)
Definition: tm.h:423
TStr GetHMSTColonDotStr(const bool &FullP=false, const bool &MSecP=true) const
Definition: tm.cpp:983
int GetSecInt() const
Definition: tm.h:393
static TSecTm GetCurTm()
Definition: tm.cpp:697
int GetDayOfWeek() const
Definition: tm.h:279
TStr GetTmStr() const
Definition: tm.cpp:520
static TTm GetTmFromMSecs(const uint64 &MSecs)
Definition: tm.cpp:1076
TStr GetWebLogTimeStr() const
Definition: tm.h:291
int GetSecHashCd() const
Definition: dt.h:1185
Definition: bd.h:196
static uint GetDSecs(const TSecTm &SecTm1, const TSecTm &SecTm2)
Definition: tm.cpp:683
uint Val
Definition: dt.h:1151
void AddTime(const int &Hours, const int &Mins=0, const int &Secs=0, const int &MSecs=0)
Definition: tm.cpp:1009
TVec< TStrTmPr > TStrTmPrV
Definition: tm.h:351
Definition: tm.h:12
TStr GetMonthNm() const
Definition: tm.h:277
static TSecTm GetDtTmFromMdyHmsPmStr(const TStr &MdyHmsPmStr, const char &DateSepCh='/', const char &TimeSepCh=':')
Definition: tm.cpp:800
Definition: tm.h:13
TInt DayOfWeek
Definition: tm.h:215
static int GetDayOfWeekN(const TStr &DayOfWeekNm, const TLoc &Loc=lUs)
Definition: tm.cpp:60
int GetPrimHashCd() const
Definition: tm.h:261
static uint64 GetDiffDays(const TTm &Tm1, const TTm &Tm2)
Definition: tm.h:325
TStr GetDayPart() const
Definition: tm.cpp:674
TTmStopWatch StopWatch
Definition: tm.h:436
static const int SunN
Definition: tm.h:47
static uint64 GetPerfTimerFq()
Definition: tm.cpp:1084
const char * GetStr() const
Definition: tm.h:368
TSecTm & SubHours(const int &Hours)
Definition: tm.h:166
char * CStr()
Definition: dt.h:476
TTmUnit
Definition: tm.h:11
void ResetTimer(const int &TimerId)
Definition: tm.h:424
int GetPrimHashCd() const
Definition: dt.h:1184
TStr GetYmdTmStr() const
Definition: tm.cpp:508
TSecTm & SubWeeks(const int &Weeks)
Definition: tm.h:174
TPair< TStr, TTm > TStrTmPr
Definition: tm.h:349
static const int MonN
Definition: tm.h:47
TStr GetStr(const bool &MSecP=true) const
Definition: tm.cpp:961
TSecTm & AddHours(const int &Hours)
Definition: tm.h:164
int GetSecHashCd() const
Definition: tm.h:262
double GetSec() const
Definition: tm.h:392
static uint64 GetMSecsFromTm(const TTm &Tm)
Definition: tm.cpp:1072
void SubTime(const int &Hours, const int &Mins=0, const int &Secs=0, const int &MSecs=0)
Definition: tm.cpp:1019
void Undef()
Definition: tm.h:268
static TStr GetHmFromMins(const int &Mins)
Definition: tm.cpp:81
static const int FebN
Definition: tm.h:53
void Undef()
Definition: tm.h:124
static const int MarN
Definition: tm.h:54
static const int TueN
Definition: tm.h:48
TStr GetDtMdyStr() const
Definition: tm.cpp:496
int GetPrimHashCd() const
Definition: tm.h:119
static const int JunN
Definition: tm.h:55
static uint64 GetMinMSecs()
Definition: tm.h:61
static int LastJulianDateN
Definition: tm.h:72
static TTm GetLocTmFromUniTm(const TTm &Tm)
Definition: tm.cpp:1117
Definition: tm.h:14
TSecTm Round(const TTmUnit &TmUnit) const
Definition: tm.cpp:625
Definition: tm.h:13
static bool GetTmStruct(const uint &AbsSec, struct tm &Tm)
Definition: tm.cpp:416
static const int SatN
Definition: tm.h:50
static TSecTm GetZeroTm()
Definition: tm.h:187
void Reset(const bool &Start)
Definition: tm.h:389
void StartTimer(const int &TimerId)
Definition: tm.h:417