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
TTm Class Reference

#include <tm.h>

Public Member Functions

 TTm ()
 
 TTm (const TTm &Tm)
 
 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)
 
 TTm (const TSecTm &SecTm)
 
 ~TTm ()
 
 TTm (TSIn &SIn)
 
void Save (TSOut &SOut) const
 
TTmoperator= (const TTm &Tm)
 
bool operator== (const TTm &Tm) const
 
bool operator< (const TTm &Tm) const
 
int GetMemUsed () const
 
int GetPrimHashCd () const
 
int GetSecHashCd () const
 
bool IsDef () const
 
void Undef ()
 
bool IsTimeDef () const
 
int GetYear () const
 
int GetMonth () const
 
TStr GetMonthNm () const
 
int GetDay () const
 
int GetDayOfWeek () const
 
TStr GetDayOfWeekNm () const
 
int GetHour () const
 
int GetMin () const
 
int GetSec () const
 
int GetMSec () const
 
TStr GetStr (const bool &MSecP=true) const
 
TStr GetYMDDashStr () const
 
TStr GetHMSTColonDotStr (const bool &FullP=false, const bool &MSecP=true) const
 
TStr GetWebLogDateStr () const
 
TStr GetWebLogTimeStr () const
 
TStr GetWebLogDateTimeStr (const bool &FullP=false, const TStr &DateTimeSepCh=" ", const bool &MSecP=true) const
 
TStr GetIdStr () const
 
TSecTm GetSecTm () const
 
void AddTime (const int &Hours, const int &Mins=0, const int &Secs=0, const int &MSecs=0)
 
void AddDays (const int &Days)
 
void SubTime (const int &Hours, const int &Mins=0, const int &Secs=0, const int &MSecs=0)
 
void SubDays (const int &Days)
 

Static Public Member Functions

static TTm GetCurUniTm ()
 
static TTm GetUniqueCurUniTm ()
 
static TTm GetUniqueCurUniTm (const int &UniqueSpaces, const int &UniqueSpaceN)
 
static TTm GetCurLocTm ()
 
static uint64 GetCurUniMSecs ()
 
static uint64 GetCurLocMSecs ()
 
static uint64 GetMSecsFromTm (const TTm &Tm)
 
static TTm GetTmFromMSecs (const uint64 &MSecs)
 
static uint GetMSecsFromOsStart ()
 
static uint64 GetPerfTimerFq ()
 
static uint64 GetPerfTimerTicks ()
 
static void GetDiff (const TTm &Tm1, const TTm &Tm2, int &Days, int &Hours, int &Mins, int &Secs, int &MSecs)
 
static uint64 GetDiffMSecs (const TTm &Tm1, const TTm &Tm2)
 
static uint64 GetDiffSecs (const TTm &Tm1, const TTm &Tm2)
 
static uint64 GetDiffMins (const TTm &Tm1, const TTm &Tm2)
 
static uint64 GetDiffHrs (const TTm &Tm1, const TTm &Tm2)
 
static uint64 GetDiffDays (const TTm &Tm1, const TTm &Tm2)
 
static TTm GetLocTmFromUniTm (const TTm &Tm)
 
static TTm GetUniTmFromLocTm (const TTm &Tm)
 
static TTm GetTmFromWebLogTimeStr (const TStr &TimeStr, const char TimeSepCh=':', const char MSecSepCh='.')
 
static TTm GetTmFromWebLogDateTimeStr (const TStr &DateTimeStr, const char DateSepCh='-', const char TimeSepCh=':', const char MSecSepCh='.', const char DateTimeSepCh=' ')
 
static TTm GetTmFromIdStr (const TStr &IdStr)
 
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 uint GetDateIntFromTm (const TTm &Tm)
 
static uint GetMonthIntFromTm (const TTm &Tm)
 
static uint GetYearIntFromTm (const TTm &Tm)
 
static uint GetDateTimeIntFromTm (const TTm &Tm)
 
static TTm GetTmFromDateTimeInt (const uint &DateTimeInt)
 
static TSecTm GetSecTmFromDateTimeInt (const uint &DateTimeInt)
 

Private Attributes

TInt Year
 
TInt Month
 
TInt Day
 
TInt DayOfWeek
 
TInt Hour
 
TInt Min
 
TInt Sec
 
TInt MSec
 

Detailed Description

Definition at line 213 of file tm.h.

Constructor & Destructor Documentation

TTm::TTm ( )
inline

Definition at line 218 of file tm.h.

218  :
219  Year(-1), Month(-1), Day(-1), DayOfWeek(-1),
220  Hour(-1), Min(-1), Sec(-1), MSec(-1){}
TInt MSec
Definition: tm.h:216
TInt Day
Definition: tm.h:215
TInt Sec
Definition: tm.h:216
TInt Min
Definition: tm.h:216
TInt Hour
Definition: tm.h:216
TInt Month
Definition: tm.h:215
TInt Year
Definition: tm.h:215
TInt DayOfWeek
Definition: tm.h:215
TTm::TTm ( const TTm Tm)
inline

Definition at line 221 of file tm.h.

221  :
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){}
TInt MSec
Definition: tm.h:216
TInt Day
Definition: tm.h:215
TInt Sec
Definition: tm.h:216
TInt Min
Definition: tm.h:216
TInt Hour
Definition: tm.h:216
TInt Month
Definition: tm.h:215
TInt Year
Definition: tm.h:215
TInt DayOfWeek
Definition: tm.h:215
TTm::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 
)
inline

Definition at line 224 of file tm.h.

226  :
227  Year(_Year), Month(_Month), Day(_Day), DayOfWeek(_DayOfWeek),
228  Hour(_Hour), Min(_Min), Sec(_Sec), MSec(_MSec){}
TInt MSec
Definition: tm.h:216
TInt Day
Definition: tm.h:215
TInt Sec
Definition: tm.h:216
TInt Min
Definition: tm.h:216
TInt Hour
Definition: tm.h:216
TInt Month
Definition: tm.h:215
TInt Year
Definition: tm.h:215
TInt DayOfWeek
Definition: tm.h:215
TTm::TTm ( const TSecTm SecTm)
inline

Definition at line 229 of file tm.h.

229  :
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){}
TInt MSec
Definition: tm.h:216
int GetMinN() const
Definition: tm.cpp:602
int GetYearN() const
Definition: tm.cpp:560
int GetDayOfWeekN() const
Definition: tm.cpp:584
TInt Day
Definition: tm.h:215
TInt Sec
Definition: tm.h:216
int GetMonthN() const
Definition: tm.cpp:566
TInt Min
Definition: tm.h:216
TInt Hour
Definition: tm.h:216
TInt Month
Definition: tm.h:215
int GetSecN() const
Definition: tm.cpp:608
int GetHourN() const
Definition: tm.cpp:596
int GetDayN() const
Definition: tm.cpp:578
TInt Year
Definition: tm.h:215
TInt DayOfWeek
Definition: tm.h:215
TTm::~TTm ( )
inline

Definition at line 233 of file tm.h.

233 {}
TTm::TTm ( TSIn SIn)
inline

Definition at line 234 of file tm.h.

234  :
235  Year(SIn), Month(SIn), Day(SIn), DayOfWeek(SIn),
236  Hour(SIn), Min(SIn), Sec(SIn), MSec(SIn){}
TInt MSec
Definition: tm.h:216
TInt Day
Definition: tm.h:215
TInt Sec
Definition: tm.h:216
TInt Min
Definition: tm.h:216
TInt Hour
Definition: tm.h:216
TInt Month
Definition: tm.h:215
TInt Year
Definition: tm.h:215
TInt DayOfWeek
Definition: tm.h:215

Member Function Documentation

void TTm::AddDays ( const int &  Days)
inline

Definition at line 300 of file tm.h.

300 {AddTime(Days*24);}
void AddTime(const int &Hours, const int &Mins=0, const int &Secs=0, const int &MSecs=0)
Definition: tm.cpp:1009
void TTm::AddTime ( const int &  Hours,
const int &  Mins = 0,
const int &  Secs = 0,
const int &  MSecs = 0 
)

Definition at line 1009 of file tm.cpp.

1010  {
1011  uint64 TmMSecs=TTm::GetMSecsFromTm(*this);
1012  TmMSecs+=(uint64(Hours)*uint64(3600)*uint64(1000));
1013  TmMSecs+=(uint64(Mins)*uint64(60)*uint64(1000));
1014  TmMSecs+=(uint64(Secs)*uint64(1000));
1015  TmMSecs+=uint64(MSecs);
1016  *this=GetTmFromMSecs(TmMSecs);
1017 }
unsigned long long uint64
Definition: bd.h:38
static TTm GetTmFromMSecs(const uint64 &MSecs)
Definition: tm.cpp:1076
static uint64 GetMSecsFromTm(const TTm &Tm)
Definition: tm.cpp:1072
uint64 TTm::GetCurLocMSecs ( )
static

Definition at line 1068 of file tm.cpp.

1068  {
1069  return TSysTm::GetCurLocMSecs();
1070 }
TTm TTm::GetCurLocTm ( )
static

Definition at line 1060 of file tm.cpp.

1060  {
1061  return TSysTm::GetCurLocTm();
1062 }
uint64 TTm::GetCurUniMSecs ( )
static

Definition at line 1064 of file tm.cpp.

1064  {
1065  return TSysTm::GetCurUniMSecs();
1066 }
TTm TTm::GetCurUniTm ( )
static

Definition at line 1029 of file tm.cpp.

1029  {
1030  return TSysTm::GetCurUniTm();
1031 }
uint TTm::GetDateIntFromTm ( const TTm Tm)
static

Definition at line 1242 of file tm.cpp.

1242  {
1243  return Tm.IsDef() ? GetDateTimeInt(Tm.GetYear(), Tm.GetMonth(), Tm.GetDay()) : 0;
1244 }
int GetMonth() const
Definition: tm.h:276
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
int GetYear() const
Definition: tm.h:275
int GetDay() const
Definition: tm.h:278
bool IsDef() const
Definition: tm.h:265
uint TTm::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

Definition at line 1236 of file tm.cpp.

1237  {
1238 
1239  return TSecTm(Year, Month, Day, Hour, Min, Sec).GetAbsSecs();
1240 }
TInt Day
Definition: tm.h:215
TInt Sec
Definition: tm.h:216
TInt Min
Definition: tm.h:216
TInt Hour
Definition: tm.h:216
TInt Month
Definition: tm.h:215
uint GetAbsSecs() const
Definition: tm.h:150
TInt Year
Definition: tm.h:215
Definition: tm.h:81
uint TTm::GetDateTimeIntFromTm ( const TTm Tm)
static

Definition at line 1254 of file tm.cpp.

1254  {
1255  return Tm.IsDef() ?
1256  GetDateTimeInt(Tm.GetYear(), Tm.GetMonth(),
1257  Tm.GetDay(), Tm.GetHour(), Tm.GetMin(), Tm.GetSec()) : 0;
1258 }
int GetMin() const
Definition: tm.h:282
int GetMonth() const
Definition: tm.h:276
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
int GetHour() const
Definition: tm.h:281
int GetYear() const
Definition: tm.h:275
int GetDay() const
Definition: tm.h:278
bool IsDef() const
Definition: tm.h:265
int GetSec() const
Definition: tm.h:283
int TTm::GetDay ( ) const
inline

Definition at line 278 of file tm.h.

278 {return Day;}
TInt Day
Definition: tm.h:215
int TTm::GetDayOfWeek ( ) const
inline

Definition at line 279 of file tm.h.

279 {return DayOfWeek;}
TInt DayOfWeek
Definition: tm.h:215
TStr TTm::GetDayOfWeekNm ( ) const
inline

Definition at line 280 of file tm.h.

static TStr GetDayOfWeekNm(const int &DayOfWeekN, const TLoc &Loc=lUs)
Definition: tm.cpp:71
TInt DayOfWeek
Definition: tm.h:215
void TTm::GetDiff ( const TTm Tm1,
const TTm Tm2,
int &  Days,
int &  Hours,
int &  Mins,
int &  Secs,
int &  MSecs 
)
static

Definition at line 1092 of file tm.cpp.

1093  {
1094 
1095  const uint64 DiffMSecs = TTm::GetDiffMSecs(Tm1, Tm2);
1096  const uint64 DiffSecs = DiffMSecs / 1000;
1097  const uint64 DiffMins = DiffSecs / 60;
1098  const uint64 DiffHours = DiffMins / 60;
1099 
1100  MSecs = int(DiffMSecs % 1000);
1101  Secs = int(DiffSecs % 60);
1102  Mins = int(DiffMins % 60);
1103  Hours = int(DiffHours % 24);
1104  Days = int((int)DiffHours / 24);
1105 }
static uint64 GetDiffMSecs(const TTm &Tm1, const TTm &Tm2)
Definition: tm.cpp:1107
unsigned long long uint64
Definition: bd.h:38
static uint64 TTm::GetDiffDays ( const TTm Tm1,
const TTm Tm2 
)
inlinestatic

Definition at line 325 of file tm.h.

325  {
326  return GetDiffMSecs(Tm1, Tm2)/uint64(1000*60*60*24);}
static uint64 GetDiffMSecs(const TTm &Tm1, const TTm &Tm2)
Definition: tm.cpp:1107
unsigned long long uint64
Definition: bd.h:38
static uint64 TTm::GetDiffHrs ( const TTm Tm1,
const TTm Tm2 
)
inlinestatic

Definition at line 323 of file tm.h.

323  {
324  return GetDiffMSecs(Tm1, Tm2)/uint64(1000*60*60);}
static uint64 GetDiffMSecs(const TTm &Tm1, const TTm &Tm2)
Definition: tm.cpp:1107
unsigned long long uint64
Definition: bd.h:38
static uint64 TTm::GetDiffMins ( const TTm Tm1,
const TTm Tm2 
)
inlinestatic

Definition at line 321 of file tm.h.

321  {
322  return GetDiffMSecs(Tm1, Tm2)/uint64(1000*60);}
static uint64 GetDiffMSecs(const TTm &Tm1, const TTm &Tm2)
Definition: tm.cpp:1107
unsigned long long uint64
Definition: bd.h:38
uint64 TTm::GetDiffMSecs ( const TTm Tm1,
const TTm Tm2 
)
static

Definition at line 1107 of file tm.cpp.

1107  {
1108  uint64 Tm1MSecs=GetMSecsFromTm(Tm1);
1109  uint64 Tm2MSecs=GetMSecsFromTm(Tm2);
1110  if (Tm1MSecs>Tm2MSecs){
1111  return Tm1MSecs-Tm2MSecs;
1112  } else {
1113  return Tm2MSecs-Tm1MSecs;
1114  }
1115 }
unsigned long long uint64
Definition: bd.h:38
static uint64 GetMSecsFromTm(const TTm &Tm)
Definition: tm.cpp:1072
static uint64 TTm::GetDiffSecs ( const TTm Tm1,
const TTm Tm2 
)
inlinestatic

Definition at line 319 of file tm.h.

319  {
320  return GetDiffMSecs(Tm1, Tm2)/uint64(1000);}
static uint64 GetDiffMSecs(const TTm &Tm1, const TTm &Tm2)
Definition: tm.cpp:1107
unsigned long long uint64
Definition: bd.h:38
TStr TTm::GetHMSTColonDotStr ( const bool &  FullP = false,
const bool &  MSecP = true 
) const

Definition at line 983 of file tm.cpp.

983  {
984  TChA ChA;
985  ChA+=TInt::GetStr(Hour, "%02d");
986  ChA+=':'; ChA+=TInt::GetStr(Min, "%02d");
987  if (FullP||((Sec!=0)||(MSec!=0))){
988  ChA+=':'; ChA+=TInt::GetStr(Sec, "%02d");
989  if ((MSecP)&&(FullP||(MSec!=0))){
990  ChA+='.'; ChA+=TInt::GetStr(MSec, "%d");
991  }
992  }
993  return ChA;
994 }
TInt MSec
Definition: tm.h:216
TStr GetStr() const
Definition: dt.h:1107
TInt Sec
Definition: tm.h:216
TInt Min
Definition: tm.h:216
TInt Hour
Definition: tm.h:216
Definition: dt.h:201
int TTm::GetHour ( ) const
inline

Definition at line 281 of file tm.h.

281 {return Hour;}
TInt Hour
Definition: tm.h:216
TStr TTm::GetIdStr ( ) const

Definition at line 996 of file tm.cpp.

996  {
997  TChA ChA;
998  ChA+=TInt::GetStr(Year%100, "%02d");
999  ChA+=TInt::GetStr(Month, "%02d");
1000  ChA+=TInt::GetStr(Day, "%02d");
1001  ChA+=TInt::GetStr(Hour, "%02d");
1002  ChA+=TInt::GetStr(Min, "%02d");
1003  ChA+=TInt::GetStr(Sec, "%02d");
1004  ChA+=TInt::GetStr(MSec, "%03d");
1005  return ChA;
1006 }
TInt MSec
Definition: tm.h:216
TStr GetStr() const
Definition: dt.h:1107
TInt Day
Definition: tm.h:215
TInt Sec
Definition: tm.h:216
TInt Min
Definition: tm.h:216
TInt Hour
Definition: tm.h:216
TInt Month
Definition: tm.h:215
TInt Year
Definition: tm.h:215
Definition: dt.h:201
TTm TTm::GetLocTmFromUniTm ( const TTm Tm)
static

Definition at line 1117 of file tm.cpp.

1117  {
1118  return TSysTm::GetLocTmFromUniTm(Tm);
1119 }
int TTm::GetMemUsed ( ) const
inline

Definition at line 259 of file tm.h.

259 {return sizeof(TTm);}
TTm()
Definition: tm.h:218
int TTm::GetMin ( ) const
inline

Definition at line 282 of file tm.h.

282 {return Min;}
TInt Min
Definition: tm.h:216
int TTm::GetMonth ( ) const
inline

Definition at line 276 of file tm.h.

276 {return Month;}
TInt Month
Definition: tm.h:215
uint TTm::GetMonthIntFromTm ( const TTm Tm)
static

Definition at line 1246 of file tm.cpp.

1246  {
1247  return Tm.IsDef() ? GetDateTimeInt(Tm.GetYear(), Tm.GetMonth()) : 0;
1248 }
int GetMonth() const
Definition: tm.h:276
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
int GetYear() const
Definition: tm.h:275
bool IsDef() const
Definition: tm.h:265
TStr TTm::GetMonthNm ( ) const
inline

Definition at line 277 of file tm.h.

277 {return TTmInfo::GetMonthNm(Month+1);}
TInt Month
Definition: tm.h:215
static TStr GetMonthNm(const int &MonthN, const TLoc &Loc=lUs)
Definition: tm.cpp:50
int TTm::GetMSec ( ) const
inline

Definition at line 284 of file tm.h.

284 {return MSec;}
TInt MSec
Definition: tm.h:216
uint TTm::GetMSecsFromOsStart ( )
static

Definition at line 1080 of file tm.cpp.

1080  {
1081  return TSysTm::GetMSecsFromOsStart();
1082 }
uint64 TTm::GetMSecsFromTm ( const TTm Tm)
static

Definition at line 1072 of file tm.cpp.

1072  {
1073  return TSysTm::GetMSecsFromTm(Tm);
1074 }
uint64 TTm::GetPerfTimerFq ( )
static

Definition at line 1084 of file tm.cpp.

1084  {
1085  return TSysTm::GetPerfTimerFq();
1086 }
uint64 TTm::GetPerfTimerTicks ( )
static

Definition at line 1088 of file tm.cpp.

1088  {
1089  return TSysTm::GetPerfTimerTicks();
1090 }
int TTm::GetPrimHashCd ( ) const
inline

Definition at line 261 of file tm.h.

261 {return Year*Month*Day+Hour*Min*Sec*MSec;}
TInt MSec
Definition: tm.h:216
TInt Day
Definition: tm.h:215
TInt Sec
Definition: tm.h:216
TInt Min
Definition: tm.h:216
TInt Hour
Definition: tm.h:216
TInt Month
Definition: tm.h:215
TInt Year
Definition: tm.h:215
int TTm::GetSec ( ) const
inline

Definition at line 283 of file tm.h.

283 {return Sec;}
TInt Sec
Definition: tm.h:216
int TTm::GetSecHashCd ( ) const
inline

Definition at line 262 of file tm.h.

262 {return Year*Month*Day;}
TInt Day
Definition: tm.h:215
TInt Month
Definition: tm.h:215
TInt Year
Definition: tm.h:215
TSecTm TTm::GetSecTm ( ) const
inline

Definition at line 295 of file tm.h.

295  {
296  return TSecTm(Year, Month, Day, Hour, Min, Sec);}
TInt Day
Definition: tm.h:215
TInt Sec
Definition: tm.h:216
TInt Min
Definition: tm.h:216
TInt Hour
Definition: tm.h:216
TInt Month
Definition: tm.h:215
TInt Year
Definition: tm.h:215
Definition: tm.h:81
TSecTm TTm::GetSecTmFromDateTimeInt ( const uint DateTimeInt)
static

Definition at line 1265 of file tm.cpp.

1265  {
1266  if (DateTimeInt == 0) { return TSecTm(); }
1267  return TSecTm(DateTimeInt);
1268 }
Definition: tm.h:81
TStr TTm::GetStr ( const bool &  MSecP = true) const

Definition at line 961 of file tm.cpp.

961  {
962  TChA ChA;
963  ChA+=TInt::GetStr(Year, "%04d"); ChA+='-';
964 // ChA+=GetMonthNm(); ChA+='-';
965  ChA+=TInt::GetStr(Month, "%02d"); ChA+='-';
966  ChA+=TInt::GetStr(Day, "%02d"); ChA+=' ';
967 // ChA+=GetDayOfWeekNm(); ChA+=' ';
968  ChA+=TInt::GetStr(Hour, "%02d"); ChA+=':';
969  ChA+=TInt::GetStr(Min, "%02d"); ChA+=':';
970  ChA+=TInt::GetStr(Sec, "%02d");
971  if (MSecP){ChA+='.'; ChA+=TInt::GetStr(MSec, "%03d");}
972  return ChA;
973 }
TInt MSec
Definition: tm.h:216
TStr GetStr() const
Definition: dt.h:1107
TInt Day
Definition: tm.h:215
TInt Sec
Definition: tm.h:216
TInt Min
Definition: tm.h:216
TInt Hour
Definition: tm.h:216
TInt Month
Definition: tm.h:215
TInt Year
Definition: tm.h:215
Definition: dt.h:201
TTm TTm::GetTmFromDateTimeInt ( const uint DateTimeInt)
static

Definition at line 1260 of file tm.cpp.

1260  {
1261  if (DateTimeInt == 0) { return TTm(); }
1262  return TTm(TSecTm(DateTimeInt));
1263 }
TTm()
Definition: tm.h:218
Definition: tm.h:81
TTm TTm::GetTmFromIdStr ( const TStr IdStr)
static

Definition at line 1215 of file tm.cpp.

1215  {
1216  // normalize
1217  TChA IdChA=IdStr;
1218  if (IdChA.Len()==14){
1219  IdChA.Ins(0, "0");}
1220  // check
1221  IAssert(IdChA.Len()==15);
1222  for (int ChN=0; ChN<IdChA.Len(); ChN++){
1223  IAssert(TCh::IsNum(IdChA[ChN]));}
1224  // extract parts
1225  int YearN=2000+(TStr(IdChA[0])+TStr(IdChA[1])).GetInt();
1226  int MonthN=(TStr(IdChA[2])+TStr(IdChA[3])).GetInt();
1227  int DayN=(TStr(IdChA[4])+TStr(IdChA[5])).GetInt();
1228  int HourN=(TStr(IdChA[6])+TStr(IdChA[7])).GetInt();
1229  int MinN=(TStr(IdChA[8])+TStr(IdChA[9])).GetInt();
1230  int SecN=(TStr(IdChA[10])+TStr(IdChA[11])).GetInt();
1231  int MSecN=(TStr(IdChA[12])+TStr(IdChA[13])+TStr(IdChA[14])).GetInt();
1232  TTm Tm=TTm(YearN, MonthN, DayN, -1, HourN, MinN, SecN, MSecN);
1233  return Tm;
1234 }
#define IAssert(Cond)
Definition: bd.h:262
void Ins(const int &BChN, const char *CStr)
Definition: dt.cpp:407
static bool IsNum(const char &Ch)
Definition: dt.h:974
int Len() const
Definition: dt.h:259
TTm()
Definition: tm.h:218
Definition: tm.h:213
Definition: dt.h:201
Definition: dt.h:412
TTm TTm::GetTmFromMSecs ( const uint64 MSecs)
static

Definition at line 1076 of file tm.cpp.

1076  {
1077  return TSysTm::GetTmFromMSecs(MSecs);
1078 }
TTm TTm::GetTmFromWebLogDateTimeStr ( const TStr DateTimeStr,
const char  DateSepCh = '-',
const char  TimeSepCh = ':',
const char  MSecSepCh = '.',
const char  DateTimeSepCh = ' ' 
)
static

Definition at line 1159 of file tm.cpp.

1161  {
1162  int DateTimeStrLen=DateTimeStr.Len();
1163  // year
1164  TChA ChA; int ChN=0;
1165  while ((ChN<DateTimeStrLen)&&(DateTimeStr[ChN]!=DateSepCh)){
1166  ChA+=DateTimeStr[ChN]; ChN++;}
1167  TStr YearStr=ChA;
1168  // month
1169  ChA.Clr(); ChN++;
1170  while ((ChN<DateTimeStrLen)&&(DateTimeStr[ChN]!=DateSepCh)){
1171  ChA+=DateTimeStr[ChN]; ChN++;}
1172  TStr MonthStr=ChA;
1173  // day
1174  ChA.Clr(); ChN++;
1175  while ((ChN<DateTimeStrLen)&&(DateTimeStr[ChN]!=DateTimeSepCh)){
1176  ChA+=DateTimeStr[ChN]; ChN++;}
1177  TStr DayStr=ChA;
1178  // hour
1179  ChA.Clr(); ChN++;
1180  while ((ChN<DateTimeStrLen)&&(DateTimeStr[ChN]!=TimeSepCh)){
1181  ChA+=DateTimeStr[ChN]; ChN++;}
1182  TStr HourStr=ChA;
1183  // minute
1184  ChA.Clr(); ChN++;
1185  while ((ChN<DateTimeStrLen)&&(DateTimeStr[ChN]!=TimeSepCh)){
1186  ChA+=DateTimeStr[ChN]; ChN++;}
1187  TStr MinStr=ChA;
1188  // second
1189  ChA.Clr(); ChN++;
1190  while ((ChN<DateTimeStrLen)&&(DateTimeStr[ChN]!=MSecSepCh)){
1191  ChA+=DateTimeStr[ChN]; ChN++;}
1192  TStr SecStr=ChA;
1193  // mili-second
1194  ChA.Clr(); ChN++;
1195  while (ChN<DateTimeStrLen){
1196  ChA+=DateTimeStr[ChN]; ChN++;}
1197  TStr MSecStr=ChA;
1198  // transform to numbers
1199  int YearN=YearStr.GetInt(-1);
1200  int MonthN=MonthStr.GetInt(-1);
1201  int DayN=DayStr.GetInt(-1);
1202  int HourN=HourStr.GetInt(0);
1203  int MinN=MinStr.GetInt(0);
1204  int SecN=SecStr.GetInt(0);
1205  int MSecN=MSecStr.GetInt(0);
1206  // construct time
1207  TTm Tm;
1208  if ((YearN!=-1)&&(MonthN!=-1)&&(DayN!=-1)){
1209  Tm=TTm(YearN, MonthN, DayN, -1, HourN, MinN, SecN, MSecN);
1210  }
1211  // return time
1212  return Tm;
1213 }
int GetInt() const
Definition: dt.h:578
int Len() const
Definition: dt.h:487
void Clr()
Definition: dt.h:258
TTm()
Definition: tm.h:218
Definition: tm.h:213
Definition: dt.h:201
Definition: dt.h:412
TTm TTm::GetTmFromWebLogTimeStr ( const TStr TimeStr,
const char  TimeSepCh = ':',
const char  MSecSepCh = '.' 
)
static

Definition at line 1125 of file tm.cpp.

1126  {
1127  int TimeStrLen=TimeStr.Len();
1128  // year
1129  TChA ChA; int ChN=0;
1130  while ((ChN<TimeStrLen)&&(TimeStr[ChN]!=TimeSepCh)){
1131  ChA+=TimeStr[ChN]; ChN++;}
1132  TStr HourStr=ChA;
1133  // minute
1134  ChA.Clr(); ChN++;
1135  while ((ChN<TimeStrLen)&&(TimeStr[ChN]!=TimeSepCh)){
1136  ChA+=TimeStr[ChN]; ChN++;}
1137  TStr MinStr=ChA;
1138  // second
1139  ChA.Clr(); ChN++;
1140  while ((ChN<TimeStrLen)&&(TimeStr[ChN]!=MSecSepCh)){
1141  ChA+=TimeStr[ChN]; ChN++;}
1142  TStr SecStr=ChA;
1143  // mili-second
1144  ChA.Clr(); ChN++;
1145  while (ChN<TimeStrLen){
1146  ChA+=TimeStr[ChN]; ChN++;}
1147  TStr MSecStr=ChA;
1148  // transform to numbers
1149  int HourN=HourStr.GetInt(0);
1150  int MinN=MinStr.GetInt(0);
1151  int SecN=SecStr.GetInt(0);
1152  int MSecN=MSecStr.GetInt(0);
1153  // construct time
1154  TTm Tm(-1, -1, -1, -1, HourN, MinN, SecN, MSecN);
1155  // return time
1156  return Tm;
1157 }
int GetInt() const
Definition: dt.h:578
int Len() const
Definition: dt.h:487
void Clr()
Definition: dt.h:258
Definition: tm.h:213
Definition: dt.h:201
Definition: dt.h:412
TTm TTm::GetUniqueCurUniTm ( )
static

Definition at line 1033 of file tm.cpp.

1033  {
1034  static TTm LastUniqueTm=TSysTm::GetCurUniTm();
1035  TTm CurUniqueTm=TSysTm::GetCurUniTm();
1036  if (CurUniqueTm<LastUniqueTm){CurUniqueTm=LastUniqueTm;}
1037  if (CurUniqueTm==LastUniqueTm){CurUniqueTm.AddTime(0, 0, 0, 1);}
1038  LastUniqueTm=CurUniqueTm;
1039  return CurUniqueTm;
1040 }
Definition: tm.h:213
void AddTime(const int &Hours, const int &Mins=0, const int &Secs=0, const int &MSecs=0)
Definition: tm.cpp:1009
TTm TTm::GetUniqueCurUniTm ( const int &  UniqueSpaces,
const int &  UniqueSpaceN 
)
static

Definition at line 1042 of file tm.cpp.

1042  {
1043  static uint64 LastMUniqueTmMSecs=TSysTm::GetCurUniMSecs();
1044  // uniqueness-space-parameters range-check
1045  Assert(UniqueSpaces>=1&&UniqueSpaceN>=0&&UniqueSpaceN<UniqueSpaces);
1046  // get current time
1047  uint64 CurUniqueTmMSecs=TSysTm::GetCurUniMSecs();
1048  if (CurUniqueTmMSecs<LastMUniqueTmMSecs){CurUniqueTmMSecs=LastMUniqueTmMSecs;}
1049  // normalize to uniqueness-space-grid
1050  CurUniqueTmMSecs-=CurUniqueTmMSecs%UniqueSpaces; CurUniqueTmMSecs+=UniqueSpaceN;
1051  // get next free unique-time
1052  if (CurUniqueTmMSecs<=LastMUniqueTmMSecs){
1053  CurUniqueTmMSecs+=UniqueSpaces;
1054  }
1055  // update last-time
1056  LastMUniqueTmMSecs=CurUniqueTmMSecs;
1057  return GetTmFromMSecs(CurUniqueTmMSecs);
1058 }
unsigned long long uint64
Definition: bd.h:38
#define Assert(Cond)
Definition: bd.h:251
static TTm GetTmFromMSecs(const uint64 &MSecs)
Definition: tm.cpp:1076
TTm TTm::GetUniTmFromLocTm ( const TTm Tm)
static

Definition at line 1121 of file tm.cpp.

1121  {
1122  return TSysTm::GetUniTmFromLocTm(Tm);
1123 }
TStr TTm::GetWebLogDateStr ( ) const
inline

Definition at line 290 of file tm.h.

290 {return GetYMDDashStr();}
TStr GetYMDDashStr() const
Definition: tm.cpp:975
TStr TTm::GetWebLogDateTimeStr ( const bool &  FullP = false,
const TStr DateTimeSepCh = " ",
const bool &  MSecP = true 
) const
inline

Definition at line 292 of file tm.h.

292  {
293  return GetYMDDashStr()+DateTimeSepCh+GetHMSTColonDotStr(FullP, MSecP);}
TStr GetYMDDashStr() const
Definition: tm.cpp:975
TStr GetHMSTColonDotStr(const bool &FullP=false, const bool &MSecP=true) const
Definition: tm.cpp:983
TStr TTm::GetWebLogTimeStr ( ) const
inline

Definition at line 291 of file tm.h.

291 {return GetHMSTColonDotStr(false);}
TStr GetHMSTColonDotStr(const bool &FullP=false, const bool &MSecP=true) const
Definition: tm.cpp:983
int TTm::GetYear ( ) const
inline

Definition at line 275 of file tm.h.

275 {return Year;}
TInt Year
Definition: tm.h:215
uint TTm::GetYearIntFromTm ( const TTm Tm)
static

Definition at line 1250 of file tm.cpp.

1250  {
1251  return Tm.IsDef() ? GetDateTimeInt(Tm.GetYear()) : 0;
1252 }
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
int GetYear() const
Definition: tm.h:275
bool IsDef() const
Definition: tm.h:265
TStr TTm::GetYMDDashStr ( ) const

Definition at line 975 of file tm.cpp.

975  {
976  TChA ChA;
977  ChA+=TInt::GetStr(Year, "%04d");
978  ChA+='-'; ChA+=TInt::GetStr(Month, "%02d");
979  ChA+='-'; ChA+=TInt::GetStr(Day, "%02d");
980  return ChA;
981 }
TStr GetStr() const
Definition: dt.h:1107
TInt Day
Definition: tm.h:215
TInt Month
Definition: tm.h:215
TInt Year
Definition: tm.h:215
Definition: dt.h:201
bool TTm::IsDef ( ) const
inline

Definition at line 265 of file tm.h.

265  {
266  return (Year!=-1)&&(Month!=-1)&&(Day!=-1)&&
267  (Hour!=-1)&&(Min!=-1)&&(Sec!=-1)&&(MSec!=-1);}
TInt MSec
Definition: tm.h:216
TInt Day
Definition: tm.h:215
TInt Sec
Definition: tm.h:216
TInt Min
Definition: tm.h:216
TInt Hour
Definition: tm.h:216
TInt Month
Definition: tm.h:215
TInt Year
Definition: tm.h:215
bool TTm::IsTimeDef ( ) const
inline

Definition at line 272 of file tm.h.

272 { return !(Hour==0 && Min==0 && Sec==0 && MSec==0); }
TInt MSec
Definition: tm.h:216
TInt Sec
Definition: tm.h:216
TInt Min
Definition: tm.h:216
TInt Hour
Definition: tm.h:216
bool TTm::operator< ( const TTm Tm) const
inline

Definition at line 249 of file tm.h.

249  {
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
TInt MSec
Definition: tm.h:216
TInt Day
Definition: tm.h:215
TInt Sec
Definition: tm.h:216
TInt Min
Definition: tm.h:216
TInt Hour
Definition: tm.h:216
TInt Month
Definition: tm.h:215
TInt Year
Definition: tm.h:215
TTm& TTm::operator= ( const TTm Tm)
inline

Definition at line 241 of file tm.h.

241  {
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;}
TInt MSec
Definition: tm.h:216
TInt Day
Definition: tm.h:215
TInt Sec
Definition: tm.h:216
TInt Min
Definition: tm.h:216
TInt Hour
Definition: tm.h:216
TInt Month
Definition: tm.h:215
TInt Year
Definition: tm.h:215
TInt DayOfWeek
Definition: tm.h:215
bool TTm::operator== ( const TTm Tm) const
inline

Definition at line 245 of file tm.h.

245  {
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);}
TInt MSec
Definition: tm.h:216
TInt Day
Definition: tm.h:215
TInt Sec
Definition: tm.h:216
TInt Min
Definition: tm.h:216
TInt Hour
Definition: tm.h:216
TInt Month
Definition: tm.h:215
TInt Year
Definition: tm.h:215
void TTm::Save ( TSOut SOut) const
inline

Definition at line 237 of file tm.h.

237  {
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);}
TInt MSec
Definition: tm.h:216
void Save(TSOut &SOut) const
Definition: dt.h:1060
TInt Day
Definition: tm.h:215
TInt Sec
Definition: tm.h:216
TInt Min
Definition: tm.h:216
TInt Hour
Definition: tm.h:216
TInt Month
Definition: tm.h:215
TInt Year
Definition: tm.h:215
TInt DayOfWeek
Definition: tm.h:215
void TTm::SubDays ( const int &  Days)
inline

Definition at line 302 of file tm.h.

302 {SubTime(Days*24);}
void SubTime(const int &Hours, const int &Mins=0, const int &Secs=0, const int &MSecs=0)
Definition: tm.cpp:1019
void TTm::SubTime ( const int &  Hours,
const int &  Mins = 0,
const int &  Secs = 0,
const int &  MSecs = 0 
)

Definition at line 1019 of file tm.cpp.

1020  {
1021  uint64 TmMSecs=TTm::GetMSecsFromTm(*this);
1022  TmMSecs-=(uint64(Hours)*uint64(3600)*uint64(1000));
1023  TmMSecs-=(uint64(Mins)*uint64(60)*uint64(1000));
1024  TmMSecs-=(uint64(Secs)*uint64(1000));
1025  TmMSecs-=(uint64(MSecs));
1026  *this=GetTmFromMSecs(TmMSecs);
1027 }
unsigned long long uint64
Definition: bd.h:38
static TTm GetTmFromMSecs(const uint64 &MSecs)
Definition: tm.cpp:1076
static uint64 GetMSecsFromTm(const TTm &Tm)
Definition: tm.cpp:1072
void TTm::Undef ( )
inline

Definition at line 268 of file tm.h.

268  {
269  Year=-1; Month=-1; Day=-1; DayOfWeek=-1;
270  Hour=-1; Min=-1; Sec=-1; MSec=-1;}
TInt MSec
Definition: tm.h:216
TInt Day
Definition: tm.h:215
TInt Sec
Definition: tm.h:216
TInt Min
Definition: tm.h:216
TInt Hour
Definition: tm.h:216
TInt Month
Definition: tm.h:215
TInt Year
Definition: tm.h:215
TInt DayOfWeek
Definition: tm.h:215

Member Data Documentation

TInt TTm::Day
private

Definition at line 215 of file tm.h.

TInt TTm::DayOfWeek
private

Definition at line 215 of file tm.h.

TInt TTm::Hour
private

Definition at line 216 of file tm.h.

TInt TTm::Min
private

Definition at line 216 of file tm.h.

TInt TTm::Month
private

Definition at line 215 of file tm.h.

TInt TTm::MSec
private

Definition at line 216 of file tm.h.

TInt TTm::Sec
private

Definition at line 216 of file tm.h.

TInt TTm::Year
private

Definition at line 215 of file tm.h.


The documentation for this class was generated from the following files: