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);
90 static time_t
MkGmTime(
struct tm *t);
93 explicit TSecTm(
const uint& _AbsSecs): AbsSecs(_AbsSecs){}
94 operator uint()
const {
return AbsSecs.
Val;}
96 TSecTm(
const int& YearN,
const int& MonthN,
const int& DayN,
97 const int& HourN=0,
const int& MinN=0,
const int& SecN=0);
106 AbsSecs=SecTm.
AbsSecs;
return *
this;}
108 AbsSecs=_AbsSecs;
return *
this;}
114 return AbsSecs==SecTm.
AbsSecs;}
149 void GetComps(
int& Year,
int& Month,
int& Day,
int& Hour,
int& Min,
int& Sec)
const;
195 const char& DateSepCh=
'/',
const char& TimeSepCh=
':');
197 const char& DateSepCh=
'-',
const char& TimeSepCh=
':');
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);
219 Year(-1), Month(-1), Day(-1), DayOfWeek(-1),
220 Hour(-1), Min(-1), Sec(-1), MSec(-1){}
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){}
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){}
235 Year(SIn), Month(SIn), Day(SIn), DayOfWeek(SIn),
236 Hour(SIn), Min(SIn), Sec(SIn), MSec(SIn){}
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))));}
266 return (Year!=-1)&&(Month!=-1)&&(Day!=-1)&&
267 (Hour!=-1)&&(Min!=-1)&&(Sec!=-1)&&(MSec!=-1);}
269 Year=-1; Month=-1; Day=-1; DayOfWeek=-1;
270 Hour=-1; Min=-1; Sec=-1; MSec=-1;}
272 bool IsTimeDef()
const {
return !(Hour==0 && Min==0 && Sec==0 && MSec==0); }
296 return TSecTm(Year, Month, Day, Hour, Min, Sec);}
299 void AddTime(
const int& Hours,
const int& Mins=0,
const int& Secs=0,
const int& MSecs=0);
301 void SubTime(
const int& Hours,
const int& Mins=0,
const int& Secs=0,
const int& MSecs=0);
316 static void GetDiff(
const TTm& Tm1,
const TTm& Tm2,
int& Days,
317 int& Hours,
int& Mins,
int& Secs,
int& MSecs);
330 const char TimeSepCh=
':',
const char MSecSepCh=
'.');
332 const char DateSepCh=
'-',
const char TimeSepCh=
':',
333 const char MSecSepCh=
'.',
const char DateTimeSepCh=
' ');
338 const int& Day = 1,
const int& Hour = 0,
const int& Min = 0,
362 LastTick=Tm.
LastTick;
return *
this;}
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);}
370 const char*
GetTmStr()
const {
static char TmStr[32];
373 else { sprintf(TmStr,
"%02dh%02dm",
int(
GetSecs())/3600, (
int(
GetSecs())%3600)/60); }
return TmStr; }
387 void Start() {
if (!RunningP) { RunningP =
true; ExeTm.
Tick(); } }
388 void Stop() {
if (RunningP) { RunningP =
false; TmSoFar += ExeTm.
GetTime(); } }
392 double GetSec()
const {
return double(
GetTime()) / double(CLOCKS_PER_SEC); }
394 double GetMSec()
const {
return double(
GetTime()) / double(CLOCKS_PER_SEC/1000); }
409 int AddTimer(
const TStr& TimerNm);
417 void StartTimer(
const int& TimerId) { TimerH[TimerId].Start(); }
420 void StopTimer(
const int& TimerId) { TimerH[TimerId].Stop(); }
424 void ResetTimer(
const int& TimerId) { TimerH[TimerId].Reset(
false); }
426 double GetTimerSumSec()
const;
427 double GetTimerSec(
const int& TimerId)
const;
428 void PrintReport(
const TStr& ProfileNm =
"")
const;
440 TTmTimer(
const int& _MxMSecs): MxMSecs(_MxMSecs), StopWatch(true) { }
void GetComps(int &Year, int &Month, int &Day, int &Hour, int &Min, int &Sec) const
TStr GetWebLogDateStr() const
TStr GetYmdTmStr2() const
static TStrV SiDayOfWeekNmV
bool GetTimerIdFNext(int &TimerId) const
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)
static void GetCalendarDate(int jdn, int &dd, int &mm, int &yy)
TSecTm & AddDays(const int &Days)
TPair< TTm, TStr > TTmStrPr
static TSecTm GetDtTmFromYmdHmsStr(const TStr &YmdHmsPmStr, const char &DateSepCh='-', const char &TimeSepCh=':')
static uint64 GetDayMSecs()
static uint64 GetCurLocMSecs()
static void InitDayOfWeekNmV()
TStr GetWebLogDateTimeStr(const bool &FullP=false, const TStr &DateTimeSepCh=" ", const bool &MSecP=true) const
static uint64 GetDiffMins(const TTm &Tm1, const TTm &Tm2)
static uint GetDateIntFromTm(const TTm &Tm)
TSecTm & SubSecs(const int &Secs)
static void GetDiff(const TTm &Tm1, const TTm &Tm2, int &Days, int &Hours, int &Mins, int &Secs, int &MSecs)
static int GetJulianDateN(int d, int m, int y)
static void InitMonthNmV()
TTmStopWatch(const bool &Start=false)
void Save(TSOut &SOut) const
TStr GetYMDDashStr() const
static TTm GetUniTmFromLocTm(const TTm &Tm)
static TSecTm GetDtTmFromHmsStr(const TStr &HmsStr)
static int LastJulianDate
static uint64 GetCurUniMSecs()
int GetDayOfWeekN() const
void Save(TSOut &SOut) const
static bool IsDayOfWeekNm(const TStr &DayOfWeekNm, const TLoc &Loc=lUs)
void SubDays(const int &Days)
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)
TSecTm & AddMins(const int &Mins)
static int GetTmUnitSecs(const TTmUnit &TmUnit)
bool operator==(const TTm &Tm) const
static uint64 GetHourMSecs()
PXmlTok GetXmlTok() const
static uint GetDateTimeIntFromTm(const TTm &Tm)
TSecTm & SubMins(const int &Mins)
uint GetInUnits(const TTmUnit &TmUnit) const
void SaveTxt(TOLx &Lx) const
bool operator==(const TSecTm &SecTm) const
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)
static uint64 GetDiffMSecs(const TTm &Tm1, const TTm &Tm2)
TSecTm & AddWeeks(const int &Weeks)
static TTm GetTmFromDateTimeInt(const uint &DateTimeInt)
void StopTimer(const int &TimerId)
static TTm GetTmFromWebLogDateTimeStr(const TStr &DateTimeStr, const char DateSepCh='-', const char TimeSepCh=':', const char MSecSepCh='.', const char DateTimeSepCh=' ')
TStr GetDtTmSortFNmStr() const
static TSecTm GetDtTmFromDmyStr(const TStr &DmyStr)
bool operator<(const TTm &Tm) const
static TSecTm GetSecTmFromDateTimeInt(const uint &DateTimeInt)
TTmTimer(const int &_MxMSecs)
TSecTm & SubDays(const int &Days)
void Save(TSOut &SOut) const
bool operator<(const TSecTm &SecTm) const
static TStr GetDayOfWeekNm(const int &DayOfWeekN, const TLoc &Loc=lUs)
static TSecTm GetDtTmFromMdyStr(const TStr &MdyStr)
#define ClassTP(TNm, PNm)
const char * GetTmStr() const
UndefDefaultCopyAssign(TTmTimer)
void Save(TSOut &SOut) const
static uint GetYearIntFromTm(const TTm &Tm)
TSecTm & operator+=(const uint &Secs)
TSecTm & operator=(const TSecTm &SecTm)
static bool GetTmSec(const int &YearN, const int &MonthN, const int &DayN, const int &HourN, const int &MinN, const int &SecN, uint &AbsSec)
static TSecTm GetCurDtTm()
static TTm GetTmFromIdStr(const TStr &IdStr)
TExeTm & operator=(const TExeTm &Tm)
int GetTimerId(const TStr &TimerNm) const
TSecTm & operator-=(const uint &Secs)
unsigned long long uint64
int GetTimerIdFFirst() const
TSecTm(const uint &_AbsSecs)
TSecTm & operator=(const uint &_AbsSecs)
TKeyDat< TSecTm, TStr > TSecTmStrKd
static uint GetMSecsFromOsStart()
static TStrV UsDayOfWeekNmV
static time_t MkGmTime(struct tm *t)
static uint64 GetDiffHrs(const TTm &Tm1, const TTm &Tm2)
static uint64 GetPerfTimerTicks()
static uint64 GetDiffSecs(const TTm &Tm1, const TTm &Tm2)
TStr GetDayOfWeekNm(const TLoc &Loc=lUs) const
TVec< TTmStrPr > TTmStrPrV
void StopTimer(const TStr &TimerNm)
TSecTm(const TSecTm &SecTm)
void StartTimer(const TStr &TimerNm)
static int Round(const double &Flt)
static uint64 GetWeekMSecs()
TSecTm & AddSecs(const int &Secs)
TTm & operator=(const TTm &Tm)
static TStr GetMonthNm(const int &MonthN, const TLoc &Loc=lUs)
static TSecTm GetZeroWeekTm()
static TSecTm GetDtTm(const int &YearN, const int &MonthN, const int &DayN)
static TStr GetTmZoneDiffStr(const TStr &TmZoneStr)
static TSecTm LoadTxt(TILx &Lx)
TVec< TSecTmStrKd > TSecTmStrKdV
TStr GetTimerNm(const int &TimerId) const
static TStr GetTmUnitStr(const TTmUnit &TmUnit)
TStr GetDayOfWeekNm() const
TStr GetDtTmSortStr() const
static uint GetMonthIntFromTm(const TTm &Tm)
TStr GetMonthNm(const TLoc &Loc=lUs) const
static TTm GetUniqueCurUniTm()
static TTm GetTmFromWebLogTimeStr(const TStr &TimeStr, const char TimeSepCh=':', const char MSecSepCh='.')
TStr GetStr(const TLoc &Loc=lUs) const
static bool IsMonthNm(const TStr &MonthNm, const TLoc &Loc=lUs)
static int GetMonthN(const TStr &MonthNm, const TLoc &Loc=lUs)
TStr GetDtStr(const TLoc &Loc=lUs) const
void AddDays(const int &Days)
void ResetTimer(const TStr &TimerNm)
TStr GetHMSTColonDotStr(const bool &FullP=false, const bool &MSecP=true) const
static TTm GetTmFromMSecs(const uint64 &MSecs)
TStr GetWebLogTimeStr() const
static uint GetDSecs(const TSecTm &SecTm1, const TSecTm &SecTm2)
void AddTime(const int &Hours, const int &Mins=0, const int &Secs=0, const int &MSecs=0)
TVec< TStrTmPr > TStrTmPrV
static TSecTm GetDtTmFromMdyHmsPmStr(const TStr &MdyHmsPmStr, const char &DateSepCh='/', const char &TimeSepCh=':')
static int GetDayOfWeekN(const TStr &DayOfWeekNm, const TLoc &Loc=lUs)
int GetPrimHashCd() const
static uint64 GetDiffDays(const TTm &Tm1, const TTm &Tm2)
static uint64 GetPerfTimerFq()
const char * GetStr() const
TSecTm & SubHours(const int &Hours)
void ResetTimer(const int &TimerId)
int GetPrimHashCd() const
TSecTm & SubWeeks(const int &Weeks)
TPair< TStr, TTm > TStrTmPr
TStr GetStr(const bool &MSecP=true) const
TSecTm & AddHours(const int &Hours)
static uint64 GetMSecsFromTm(const TTm &Tm)
void SubTime(const int &Hours, const int &Mins=0, const int &Secs=0, const int &MSecs=0)
static TStr GetHmFromMins(const int &Mins)
int GetPrimHashCd() const
static uint64 GetMinMSecs()
static int LastJulianDateN
static TTm GetLocTmFromUniTm(const TTm &Tm)
Vector is a sequence TVal objects representing an array that can change in size.
TSecTm Round(const TTmUnit &TmUnit) const
static bool GetTmStruct(const uint &AbsSec, struct tm &Tm)
static TSecTm GetZeroTm()
void Reset(const bool &Start)
void StartTimer(const int &TimerId)