|
SNAP Library 2.2, User Reference
2014-03-11 19:15:55
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
|
#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 |
| TTm & | operator= (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 |
| TTm::TTm | ( | ) | [inline] |
| 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] |
| void TTm::AddDays | ( | const int & | Days | ) | [inline] |
| void TTm::AddTime | ( | const int & | Hours, |
| const int & | Mins = 0, |
||
| const int & | Secs = 0, |
||
| const int & | MSecs = 0 |
||
| ) |
| uint64 TTm::GetCurLocMSecs | ( | ) | [static] |
Definition at line 1063 of file tm.cpp.
{
return TSysTm::GetCurLocMSecs();
}
| TTm TTm::GetCurLocTm | ( | ) | [static] |
Definition at line 1055 of file tm.cpp.
{
return TSysTm::GetCurLocTm();
}
| uint64 TTm::GetCurUniMSecs | ( | ) | [static] |
Definition at line 1059 of file tm.cpp.
{
return TSysTm::GetCurUniMSecs();
}
| TTm TTm::GetCurUniTm | ( | ) | [static] |
Definition at line 1024 of file tm.cpp.
{
return TSysTm::GetCurUniTm();
}
| uint TTm::GetDateIntFromTm | ( | const TTm & | Tm | ) | [static] |
| 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] |
| uint TTm::GetDateTimeIntFromTm | ( | const TTm & | Tm | ) | [static] |
| int TTm::GetDay | ( | ) | const [inline] |
| int TTm::GetDayOfWeek | ( | ) | const [inline] |
| TStr TTm::GetDayOfWeekNm | ( | ) | const [inline] |
Definition at line 279 of file tm.h.
{return TTmInfo::GetDayOfWeekNm(DayOfWeek);}
| void TTm::GetDiff | ( | const TTm & | Tm1, |
| const TTm & | Tm2, | ||
| int & | Days, | ||
| int & | Hours, | ||
| int & | Mins, | ||
| int & | Secs, | ||
| int & | MSecs | ||
| ) | [static] |
Definition at line 1087 of file tm.cpp.
{
const uint64 DiffMSecs = TTm::GetDiffMSecs(Tm1, Tm2);
const uint64 DiffSecs = DiffMSecs / 1000;
const uint64 DiffMins = DiffSecs / 60;
const uint64 DiffHours = DiffMins / 60;
MSecs = int(DiffMSecs % 1000);
Secs = int(DiffSecs % 60);
Mins = int(DiffMins % 60);
Hours = int(DiffHours % 24);
Days = int((int)DiffHours / 24);
}
| static uint64 TTm::GetDiffDays | ( | const TTm & | Tm1, |
| const TTm & | Tm2 | ||
| ) | [inline, static] |
Definition at line 324 of file tm.h.
{
return GetDiffMSecs(Tm1, Tm2)/uint64(1000*60*60*24);}
| static uint64 TTm::GetDiffHrs | ( | const TTm & | Tm1, |
| const TTm & | Tm2 | ||
| ) | [inline, static] |
Definition at line 322 of file tm.h.
{
return GetDiffMSecs(Tm1, Tm2)/uint64(1000*60*60);}
| static uint64 TTm::GetDiffMins | ( | const TTm & | Tm1, |
| const TTm & | Tm2 | ||
| ) | [inline, static] |
Definition at line 320 of file tm.h.
{
return GetDiffMSecs(Tm1, Tm2)/uint64(1000*60);}
| uint64 TTm::GetDiffMSecs | ( | const TTm & | Tm1, |
| const TTm & | Tm2 | ||
| ) | [static] |
Definition at line 1102 of file tm.cpp.
{
uint64 Tm1MSecs=GetMSecsFromTm(Tm1);
uint64 Tm2MSecs=GetMSecsFromTm(Tm2);
if (Tm1MSecs>Tm2MSecs){
return Tm1MSecs-Tm2MSecs;
} else {
return Tm2MSecs-Tm1MSecs;
}
}
| static uint64 TTm::GetDiffSecs | ( | const TTm & | Tm1, |
| const TTm & | Tm2 | ||
| ) | [inline, static] |
Definition at line 318 of file tm.h.
{
return GetDiffMSecs(Tm1, Tm2)/uint64(1000);}
| TStr TTm::GetHMSTColonDotStr | ( | const bool & | FullP = false, |
| const bool & | MSecP = true |
||
| ) | const |
Definition at line 978 of file tm.cpp.
{
TChA ChA;
ChA+=TInt::GetStr(Hour, "%02d");
ChA+=':'; ChA+=TInt::GetStr(Min, "%02d");
if (FullP||((Sec!=0)||(MSec!=0))){
ChA+=':'; ChA+=TInt::GetStr(Sec, "%02d");
if ((MSecP)&&(FullP||(MSec!=0))){
ChA+='.'; ChA+=TInt::GetStr(MSec, "%d");
}
}
return ChA;
}
| int TTm::GetHour | ( | ) | const [inline] |
| TStr TTm::GetIdStr | ( | ) | const |
Definition at line 991 of file tm.cpp.
{
TChA ChA;
ChA+=TInt::GetStr(Year%100, "%02d");
ChA+=TInt::GetStr(Month, "%02d");
ChA+=TInt::GetStr(Day, "%02d");
ChA+=TInt::GetStr(Hour, "%02d");
ChA+=TInt::GetStr(Min, "%02d");
ChA+=TInt::GetStr(Sec, "%02d");
ChA+=TInt::GetStr(MSec, "%03d");
return ChA;
}
| TTm TTm::GetLocTmFromUniTm | ( | const TTm & | Tm | ) | [static] |
Definition at line 1112 of file tm.cpp.
{
return TSysTm::GetLocTmFromUniTm(Tm);
}
| int TTm::GetMemUsed | ( | ) | const [inline] |
| int TTm::GetMin | ( | ) | const [inline] |
| int TTm::GetMonth | ( | ) | const [inline] |
| uint TTm::GetMonthIntFromTm | ( | const TTm & | Tm | ) | [static] |
| TStr TTm::GetMonthNm | ( | ) | const [inline] |
Definition at line 276 of file tm.h.
{return TTmInfo::GetMonthNm(Month+1);}
| int TTm::GetMSec | ( | ) | const [inline] |
| uint TTm::GetMSecsFromOsStart | ( | ) | [static] |
Definition at line 1075 of file tm.cpp.
{
return TSysTm::GetMSecsFromOsStart();
}
| uint64 TTm::GetMSecsFromTm | ( | const TTm & | Tm | ) | [static] |
Definition at line 1067 of file tm.cpp.
{
return TSysTm::GetMSecsFromTm(Tm);
}
| uint64 TTm::GetPerfTimerFq | ( | ) | [static] |
Definition at line 1079 of file tm.cpp.
{
return TSysTm::GetPerfTimerFq();
}
| uint64 TTm::GetPerfTimerTicks | ( | ) | [static] |
Definition at line 1083 of file tm.cpp.
{
return TSysTm::GetPerfTimerTicks();
}
| int TTm::GetPrimHashCd | ( | ) | const [inline] |
| int TTm::GetSec | ( | ) | const [inline] |
| int TTm::GetSecHashCd | ( | ) | const [inline] |
| TSecTm TTm::GetSecTm | ( | ) | const [inline] |
| TSecTm TTm::GetSecTmFromDateTimeInt | ( | const uint & | DateTimeInt | ) | [static] |
| TStr TTm::GetStr | ( | const bool & | MSecP = true | ) | const |
Definition at line 956 of file tm.cpp.
{
TChA ChA;
ChA+=TInt::GetStr(Year, "%04d"); ChA+='-';
// ChA+=GetMonthNm(); ChA+='-';
ChA+=TInt::GetStr(Month, "%02d"); ChA+='-';
ChA+=TInt::GetStr(Day, "%02d"); ChA+=' ';
// ChA+=GetDayOfWeekNm(); ChA+=' ';
ChA+=TInt::GetStr(Hour, "%02d"); ChA+=':';
ChA+=TInt::GetStr(Min, "%02d"); ChA+=':';
ChA+=TInt::GetStr(Sec, "%02d");
if (MSecP){ChA+='.'; ChA+=TInt::GetStr(MSec, "%03d");}
return ChA;
}
| TTm TTm::GetTmFromDateTimeInt | ( | const uint & | DateTimeInt | ) | [static] |
| TTm TTm::GetTmFromIdStr | ( | const TStr & | IdStr | ) | [static] |
Definition at line 1210 of file tm.cpp.
{
// normalize
TChA IdChA=IdStr;
if (IdChA.Len()==14){
IdChA.Ins(0, "0");}
// check
IAssert(IdChA.Len()==15);
for (int ChN=0; ChN<IdChA.Len(); ChN++){
IAssert(TCh::IsNum(IdChA[ChN]));}
// extract parts
int YearN=2000+(TStr(IdChA[0])+TStr(IdChA[1])).GetInt();
int MonthN=(TStr(IdChA[2])+TStr(IdChA[3])).GetInt();
int DayN=(TStr(IdChA[4])+TStr(IdChA[5])).GetInt();
int HourN=(TStr(IdChA[6])+TStr(IdChA[7])).GetInt();
int MinN=(TStr(IdChA[8])+TStr(IdChA[9])).GetInt();
int SecN=(TStr(IdChA[10])+TStr(IdChA[11])).GetInt();
int MSecN=(TStr(IdChA[12])+TStr(IdChA[13])+TStr(IdChA[14])).GetInt();
TTm Tm=TTm(YearN, MonthN, DayN, -1, HourN, MinN, SecN, MSecN);
return Tm;
}
| TTm TTm::GetTmFromMSecs | ( | const uint64 & | MSecs | ) | [static] |
Definition at line 1071 of file tm.cpp.
{
return TSysTm::GetTmFromMSecs(MSecs);
}
| TTm TTm::GetTmFromWebLogDateTimeStr | ( | const TStr & | DateTimeStr, |
| const char | DateSepCh = '-', |
||
| const char | TimeSepCh = ':', |
||
| const char | MSecSepCh = '.', |
||
| const char | DateTimeSepCh = ' ' |
||
| ) | [static] |
Definition at line 1154 of file tm.cpp.
{
int DateTimeStrLen=DateTimeStr.Len();
// year
TChA ChA; int ChN=0;
while ((ChN<DateTimeStrLen)&&(DateTimeStr[ChN]!=DateSepCh)){
ChA+=DateTimeStr[ChN]; ChN++;}
TStr YearStr=ChA;
// month
ChA.Clr(); ChN++;
while ((ChN<DateTimeStrLen)&&(DateTimeStr[ChN]!=DateSepCh)){
ChA+=DateTimeStr[ChN]; ChN++;}
TStr MonthStr=ChA;
// day
ChA.Clr(); ChN++;
while ((ChN<DateTimeStrLen)&&(DateTimeStr[ChN]!=DateTimeSepCh)){
ChA+=DateTimeStr[ChN]; ChN++;}
TStr DayStr=ChA;
// hour
ChA.Clr(); ChN++;
while ((ChN<DateTimeStrLen)&&(DateTimeStr[ChN]!=TimeSepCh)){
ChA+=DateTimeStr[ChN]; ChN++;}
TStr HourStr=ChA;
// minute
ChA.Clr(); ChN++;
while ((ChN<DateTimeStrLen)&&(DateTimeStr[ChN]!=TimeSepCh)){
ChA+=DateTimeStr[ChN]; ChN++;}
TStr MinStr=ChA;
// second
ChA.Clr(); ChN++;
while ((ChN<DateTimeStrLen)&&(DateTimeStr[ChN]!=MSecSepCh)){
ChA+=DateTimeStr[ChN]; ChN++;}
TStr SecStr=ChA;
// mili-second
ChA.Clr(); ChN++;
while (ChN<DateTimeStrLen){
ChA+=DateTimeStr[ChN]; ChN++;}
TStr MSecStr=ChA;
// transform to numbers
int YearN=YearStr.GetInt(-1);
int MonthN=MonthStr.GetInt(-1);
int DayN=DayStr.GetInt(-1);
int HourN=HourStr.GetInt(0);
int MinN=MinStr.GetInt(0);
int SecN=SecStr.GetInt(0);
int MSecN=MSecStr.GetInt(0);
// construct time
TTm Tm;
if ((YearN!=-1)&&(MonthN!=-1)&&(DayN!=-1)){
Tm=TTm(YearN, MonthN, DayN, -1, HourN, MinN, SecN, MSecN);
}
// return time
return Tm;
}
| TTm TTm::GetTmFromWebLogTimeStr | ( | const TStr & | TimeStr, |
| const char | TimeSepCh = ':', |
||
| const char | MSecSepCh = '.' |
||
| ) | [static] |
Definition at line 1120 of file tm.cpp.
{
int TimeStrLen=TimeStr.Len();
// year
TChA ChA; int ChN=0;
while ((ChN<TimeStrLen)&&(TimeStr[ChN]!=TimeSepCh)){
ChA+=TimeStr[ChN]; ChN++;}
TStr HourStr=ChA;
// minute
ChA.Clr(); ChN++;
while ((ChN<TimeStrLen)&&(TimeStr[ChN]!=TimeSepCh)){
ChA+=TimeStr[ChN]; ChN++;}
TStr MinStr=ChA;
// second
ChA.Clr(); ChN++;
while ((ChN<TimeStrLen)&&(TimeStr[ChN]!=MSecSepCh)){
ChA+=TimeStr[ChN]; ChN++;}
TStr SecStr=ChA;
// mili-second
ChA.Clr(); ChN++;
while (ChN<TimeStrLen){
ChA+=TimeStr[ChN]; ChN++;}
TStr MSecStr=ChA;
// transform to numbers
int HourN=HourStr.GetInt(0);
int MinN=MinStr.GetInt(0);
int SecN=SecStr.GetInt(0);
int MSecN=MSecStr.GetInt(0);
// construct time
TTm Tm(-1, -1, -1, -1, HourN, MinN, SecN, MSecN);
// return time
return Tm;
}
| TTm TTm::GetUniqueCurUniTm | ( | ) | [static] |
Definition at line 1028 of file tm.cpp.
{
static TTm LastUniqueTm=TSysTm::GetCurUniTm();
TTm CurUniqueTm=TSysTm::GetCurUniTm();
if (CurUniqueTm<LastUniqueTm){CurUniqueTm=LastUniqueTm;}
if (CurUniqueTm==LastUniqueTm){CurUniqueTm.AddTime(0, 0, 0, 1);}
LastUniqueTm=CurUniqueTm;
return CurUniqueTm;
}
| TTm TTm::GetUniqueCurUniTm | ( | const int & | UniqueSpaces, |
| const int & | UniqueSpaceN | ||
| ) | [static] |
Definition at line 1037 of file tm.cpp.
{
static uint64 LastMUniqueTmMSecs=TSysTm::GetCurUniMSecs();
// uniqueness-space-parameters range-check
Assert(UniqueSpaces>=1&&UniqueSpaceN>=0&&UniqueSpaceN<UniqueSpaces);
// get current time
uint64 CurUniqueTmMSecs=TSysTm::GetCurUniMSecs();
if (CurUniqueTmMSecs<LastMUniqueTmMSecs){CurUniqueTmMSecs=LastMUniqueTmMSecs;}
// normalize to uniqueness-space-grid
CurUniqueTmMSecs-=CurUniqueTmMSecs%UniqueSpaces; CurUniqueTmMSecs+=UniqueSpaceN;
// get next free unique-time
if (CurUniqueTmMSecs<=LastMUniqueTmMSecs){
CurUniqueTmMSecs+=UniqueSpaces;
}
// update last-time
LastMUniqueTmMSecs=CurUniqueTmMSecs;
return GetTmFromMSecs(CurUniqueTmMSecs);
}
| TTm TTm::GetUniTmFromLocTm | ( | const TTm & | Tm | ) | [static] |
Definition at line 1116 of file tm.cpp.
{
return TSysTm::GetUniTmFromLocTm(Tm);
}
| TStr TTm::GetWebLogDateStr | ( | ) | const [inline] |
Definition at line 289 of file tm.h.
{return GetYMDDashStr();}
| TStr TTm::GetWebLogDateTimeStr | ( | const bool & | FullP = false, |
| const TStr & | DateTimeSepCh = " ", |
||
| const bool & | MSecP = true |
||
| ) | const [inline] |
Definition at line 291 of file tm.h.
{
return GetYMDDashStr()+DateTimeSepCh+GetHMSTColonDotStr(FullP, MSecP);}
| TStr TTm::GetWebLogTimeStr | ( | ) | const [inline] |
Definition at line 290 of file tm.h.
{return GetHMSTColonDotStr(false);}
| int TTm::GetYear | ( | ) | const [inline] |
| uint TTm::GetYearIntFromTm | ( | const TTm & | Tm | ) | [static] |
Definition at line 1245 of file tm.cpp.
{
return Tm.IsDef() ? GetDateTimeInt(Tm.GetYear()) : 0;
}
| TStr TTm::GetYMDDashStr | ( | ) | const |
Definition at line 970 of file tm.cpp.
{
TChA ChA;
ChA+=TInt::GetStr(Year, "%04d");
ChA+='-'; ChA+=TInt::GetStr(Month, "%02d");
ChA+='-'; ChA+=TInt::GetStr(Day, "%02d");
return ChA;
}
| bool TTm::IsDef | ( | ) | const [inline] |
| bool TTm::IsTimeDef | ( | ) | const [inline] |
| bool TTm::operator< | ( | const TTm & | Tm | ) | const [inline] |
Definition at line 248 of file tm.h.
{
return
(Year<Tm.Year)||
((Year==Tm.Year)&&(Month<Tm.Month))||
((Year==Tm.Year)&&(Month==Tm.Month)&&(Day<Tm.Day))||
(((Year==Tm.Year)&&(Month==Tm.Month)&&(Day==Tm.Day))&&(
(Hour<Tm.Hour)||
((Hour==Tm.Hour)&&(Min<Tm.Min))||
((Hour==Tm.Hour)&&(Min==Tm.Min)&&(Sec<Tm.Sec))||
((Hour==Tm.Hour)&&(Min==Tm.Min)&&(Sec==Tm.Sec)&&(MSec<Tm.MSec))));} // saxo
| bool TTm::operator== | ( | const TTm & | Tm | ) | const [inline] |
| void TTm::SubDays | ( | const int & | Days | ) | [inline] |
| void TTm::SubTime | ( | const int & | Hours, |
| const int & | Mins = 0, |
||
| const int & | Secs = 0, |
||
| const int & | MSecs = 0 |
||
| ) |
| void TTm::Undef | ( | ) | [inline] |
TInt TTm::DayOfWeek [private] |
TInt TTm::Month [private] |