SNAP Library 2.0, Developer Reference
2013-05-13 16:33:57
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
|
#include <tm.h>
Public Member Functions | |
TSecTm () | |
TSecTm (const uint &_AbsSecs) | |
operator uint () const | |
TSecTm (const TSecTm &SecTm) | |
TSecTm (const int &YearN, const int &MonthN, const int &DayN, const int &HourN=0, const int &MinN=0, const int &SecN=0) | |
TSecTm (const TTm &Tm) | |
TSecTm (const PXmlTok &XmlTok) | |
PXmlTok | GetXmlTok () const |
TSecTm (TSIn &SIn) | |
void | Load (TSIn &SIn) |
void | Save (TSOut &SOut) const |
TSecTm & | operator= (const TSecTm &SecTm) |
TSecTm & | operator= (const uint &_AbsSecs) |
TSecTm & | operator+= (const uint &Secs) |
TSecTm & | operator-= (const uint &Secs) |
bool | operator== (const TSecTm &SecTm) const |
bool | operator< (const TSecTm &SecTm) const |
int | GetMemUsed () const |
int | GetPrimHashCd () const |
int | GetSecHashCd () const |
bool | IsDef () const |
void | Undef () |
TStr | GetStr (const TLoc &Loc=lUs) const |
TStr | GetStr (const TTmUnit &TmUnit) const |
TStr | GetDtStr (const TLoc &Loc=lUs) const |
TStr | GetDtMdyStr () const |
TStr | GetDtYmdStr () const |
TStr | GetYmdTmStr () const |
TStr | GetTmStr () const |
TStr | GetTmMinStr () const |
TStr | GetDtTmSortStr () const |
TStr | GetDtTmSortFNmStr () const |
int | GetYearN () const |
int | GetMonthN () const |
TStr | GetMonthNm (const TLoc &Loc=lUs) const |
int | GetDayN () const |
int | GetDayOfWeekN () const |
TStr | GetDayOfWeekNm (const TLoc &Loc=lUs) const |
int | GetHourN () const |
int | GetMinN () const |
int | GetSecN () const |
void | GetComps (int &Year, int &Month, int &Day, int &Hour, int &Min, int &Sec) const |
uint | GetAbsSecs () const |
TSecTm | Round (const TTmUnit &TmUnit) const |
uint | GetInUnits (const TTmUnit &TmUnit) const |
TStr | GetDayPart () const |
TSecTm & | AddSecs (const int &Secs) |
TSecTm & | SubSecs (const int &Secs) |
TSecTm & | AddMins (const int &Mins) |
TSecTm & | SubMins (const int &Mins) |
TSecTm & | AddHours (const int &Hours) |
TSecTm & | SubHours (const int &Hours) |
TSecTm & | AddDays (const int &Days) |
TSecTm & | SubDays (const int &Days) |
TSecTm & | AddWeeks (const int &Weeks) |
TSecTm & | SubWeeks (const int &Weeks) |
void | SaveTxt (TOLx &Lx) const |
Static Public Member Functions | |
static uint | GetDSecs (const TSecTm &SecTm1, const TSecTm &SecTm2) |
static TSecTm | GetZeroTm () |
static TSecTm | GetZeroWeekTm () |
static TSecTm | GetCurTm () |
static TSecTm | GetCurDtTm () |
static TSecTm | GetDtTmFromHmsStr (const TStr &HmsStr) |
static TSecTm | GetDtTmFromMdyStr (const TStr &MdyStr) |
static TSecTm | GetDtTmFromDmyStr (const TStr &DmyStr) |
static TSecTm | GetDtTmFromMdyHmsPmStr (const TStr &MdyHmsPmStr, const char &DateSepCh='/', const char &TimeSepCh=':') |
static TSecTm | GetDtTmFromYmdHmsStr (const TStr &YmdHmsPmStr, const char &DateSepCh='-', const char &TimeSepCh=':') |
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 TSecTm | GetDtTm (const int &YearN, const int &MonthN, const int &DayN) |
static TSecTm | GetDtTm (const TSecTm &Tm) |
static TSecTm | LoadTxt (TILx &Lx) |
Static Private Member Functions | |
static bool | GetTmSec (const int &YearN, const int &MonthN, const int &DayN, const int &HourN, const int &MinN, const int &SecN, uint &AbsSec) |
static bool | GetTmSec (struct tm &Tm, uint &AbsSec) |
static bool | GetTmStruct (const uint &AbsSec, struct tm &Tm) |
static time_t | MkGmTime (struct tm *t) |
Private Attributes | |
TUInt | AbsSecs |
TSecTm::TSecTm | ( | ) | [inline] |
Definition at line 92 of file tm.h.
Referenced by GetCurTm(), GetDtTm(), GetDtTmFromDmyStr(), GetDtTmFromStr(), GetInUnits(), GetZeroTm(), LoadTxt(), Round(), and TSecTm().
TSecTm::TSecTm | ( | const uint & | _AbsSecs | ) | [inline, explicit] |
TSecTm::TSecTm | ( | const TSecTm & | SecTm | ) | [inline] |
TSecTm::TSecTm | ( | const int & | YearN, |
const int & | MonthN, | ||
const int & | DayN, | ||
const int & | HourN = 0 , |
||
const int & | MinN = 0 , |
||
const int & | SecN = 0 |
||
) |
Definition at line 427 of file tm.cpp.
References AbsSecs, GetTmSec(), and TUInt::Val.
TSecTm::TSecTm | ( | const TTm & | Tm | ) |
TSecTm::TSecTm | ( | const PXmlTok & | XmlTok | ) | [explicit] |
Definition at line 436 of file tm.cpp.
References AbsSecs, TXmlTok::GetIntArgVal(), and TSecTm().
{ const int Year = XmlTok->GetIntArgVal("Year"); const int Month = XmlTok->GetIntArgVal("Month"); const int Day = XmlTok->GetIntArgVal("Day"); const int Hour = XmlTok->GetIntArgVal("Hour"); const int Min = XmlTok->GetIntArgVal("Min"); const int Sec = XmlTok->GetIntArgVal("Sec"); AbsSecs = TSecTm(Year, Month, Day, Hour, Min, Sec).GetAbsSecs(); }
TSecTm::TSecTm | ( | TSIn & | SIn | ) | [inline] |
TSecTm& TSecTm::AddDays | ( | const int & | Days | ) | [inline] |
TSecTm& TSecTm::AddHours | ( | const int & | Hours | ) | [inline] |
Definition at line 163 of file tm.h.
References AbsSecs, IAssert, IsDef(), and TUInt::Val.
Referenced by GetDtTmFromHmsStr(), GetDtTmFromMdyHmsPmStr(), and GetDtTmFromYmdHmsStr().
TSecTm& TSecTm::AddMins | ( | const int & | Mins | ) | [inline] |
Definition at line 159 of file tm.h.
References AbsSecs, IAssert, IsDef(), and TUInt::Val.
Referenced by GetDtTmFromHmsStr(), GetDtTmFromMdyHmsPmStr(), and GetDtTmFromYmdHmsStr().
TSecTm& TSecTm::AddSecs | ( | const int & | Secs | ) | [inline] |
Definition at line 155 of file tm.h.
References AbsSecs, IAssert, IsDef(), and TUInt::Val.
Referenced by GetDtTmFromHmsStr(), GetDtTmFromMdyHmsPmStr(), and GetDtTmFromYmdHmsStr().
TSecTm& TSecTm::AddWeeks | ( | const int & | Weeks | ) | [inline] |
uint TSecTm::GetAbsSecs | ( | ) | const [inline] |
Definition at line 149 of file tm.h.
References AbsSecs.
Referenced by TTm::GetDateTimeInt(), TTimeNENet::GetEdgeTmBuckets(), TTimeNENet::GetTmBuckets(), TGStat::GetVal(), TNIBs::LabelBurstAutomaton(), TAGMFast::MLEGradAscentParallel(), and TTimeNENet::SaveEdgeTm().
{return AbsSecs();}
void TSecTm::GetComps | ( | int & | Year, |
int & | Month, | ||
int & | Day, | ||
int & | Hour, | ||
int & | Min, | ||
int & | Sec | ||
) | const |
Definition at line 609 of file tm.cpp.
References AbsSecs, EAssert, GetTmStruct(), and IsDef().
{ struct tm Tm; EAssert(IsDef() && GetTmStruct(AbsSecs(), Tm)); Year = Tm.tm_year+1900; Month = Tm.tm_mon+1; Day = Tm.tm_mday; Hour = Tm.tm_hour; Min = Tm.tm_min; Sec = Tm.tm_sec; }
static TSecTm TSecTm::GetCurDtTm | ( | ) | [inline, static] |
TSecTm TSecTm::GetCurTm | ( | ) | [static] |
Definition at line 692 of file tm.cpp.
References GetTmSec(), IAssert, TUInt::Mx, and TSecTm().
Referenced by GetCurDtTm(), TTimeNENet::LoadEdgeTm(), and TAGMFast::MLEGradAscentParallel().
{ const time_t TmSec = time(NULL); struct tm LocTm; uint AbsSec = TUInt::Mx; #if defined(GLib_MSN) localtime_s(&LocTm, &TmSec); #elif defined(GLib_BCB) LocTm = *localtime(&TmSec); #else LocTm = *localtime(&TmSec); #endif IAssert(TSecTm::GetTmSec(LocTm, AbsSec)); return TSecTm(AbsSec); }
int TSecTm::GetDayN | ( | ) | const |
Definition at line 573 of file tm.cpp.
References AbsSecs, GetTmStruct(), IAssert, and IsDef().
Referenced by TGStat::GetDay(), GetDtTmSortFNmStr(), GetDtTmSortStr(), GetStr(), and GetXmlTok().
{ struct tm Tm; IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm)); return Tm.tm_mday; }
int TSecTm::GetDayOfWeekN | ( | ) | const |
Definition at line 579 of file tm.cpp.
References AbsSecs, GetTmStruct(), IAssert, and IsDef().
Referenced by GetZeroWeekTm().
{ struct tm Tm; IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm)); return Tm.tm_wday + 1; }
TStr TSecTm::GetDayOfWeekNm | ( | const TLoc & | Loc = lUs | ) | const |
Definition at line 585 of file tm.cpp.
References AbsSecs, GetTmStruct(), IAssert, and IsDef().
{ struct tm Tm; IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm)); return TTmInfo::GetDayOfWeekNm(Tm.tm_wday+1, Loc); }
TStr TSecTm::GetDayPart | ( | ) | const |
Definition at line 669 of file tm.cpp.
References GetHourN().
{ const int Hour = GetHourN(); if (0 <= Hour && Hour < 6) { return "Night"; } else if (6 <= Hour && Hour < 12) { return "Morning"; } else if (12 <= Hour && Hour < 18) { return "Afternoon"; } else if (18 <= Hour && Hour < 24) { return "Evening"; } return ""; }
uint TSecTm::GetDSecs | ( | const TSecTm & | SecTm1, |
const TSecTm & | SecTm2 | ||
) | [static] |
TStr TSecTm::GetDtMdyStr | ( | ) | const |
Definition at line 496 of file tm.cpp.
References AbsSecs, TStr::Fmt(), GetTmStruct(), and IAssert.
{ struct tm Tm; IAssert(GetTmStruct(AbsSecs(), Tm)); return TStr::Fmt("%02d/%02d%/%04d", Tm.tm_mon+1, Tm.tm_mday, Tm.tm_year+1900); }
TStr TSecTm::GetDtStr | ( | const TLoc & | Loc = lUs | ) | const |
Definition at line 484 of file tm.cpp.
References AbsSecs, TStr::CStr(), TStr::Fmt(), TTmInfo::GetDayOfWeekNm(), GetMonthNm(), GetTmStruct(), IAssert, and IsDef().
{ if (IsDef()){ struct tm Tm; IAssert(GetTmStruct(AbsSecs(), Tm)); return TStr::Fmt("%s %s %d %d", TTmInfo::GetDayOfWeekNm(Tm.tm_wday + 1, Loc).CStr(), TTmInfo::GetMonthNm(Tm.tm_mon + 1, Loc).CStr(), Tm.tm_year+1900); } else { return "Undef"; } }
TSecTm TSecTm::GetDtTm | ( | const int & | YearN, |
const int & | MonthN, | ||
const int & | DayN | ||
) | [static] |
Definition at line 933 of file tm.cpp.
References AbsSecs, GetTmSec(), and TSecTm().
Referenced by GetCurDtTm(), GetDtTmFromDmyStr(), GetDtTmFromMdyHmsPmStr(), GetDtTmFromMdyStr(), and GetDtTmFromYmdHmsStr().
{ uint AbsSecs; TSecTm::GetTmSec(YearN, MonthN, DayN, 0, 0, 0, AbsSecs); return TSecTm(AbsSecs); }
TSecTm TSecTm::GetDtTm | ( | const TSecTm & | Tm | ) | [static] |
TSecTm TSecTm::GetDtTmFromDmyStr | ( | const TStr & | DmyStr | ) | [static] |
Definition at line 761 of file tm.cpp.
References TChA::Clr(), GetDtTm(), TStr::GetInt(), GetMonthN(), TStr::Len(), TStr::ToCap(), and TSecTm().
{ int DmyStrLen=DmyStr.Len(); // day TChA ChA; int ChN=0; while ((ChN<DmyStrLen)&&(DmyStr[ChN]!='/')&&(DmyStr[ChN]!='-')){ ChA+=DmyStr[ChN]; ChN++;} TStr DayStr=ChA; // month ChA.Clr(); ChN++; while ((ChN<DmyStrLen)&&(DmyStr[ChN]!='/')&&(DmyStr[ChN]!='-')){ ChA+=DmyStr[ChN]; ChN++;} TStr MonthStr=ChA; // year ChA.Clr(); ChN++; while (ChN<DmyStrLen){ ChA+=DmyStr[ChN]; ChN++;} TStr YearStr=ChA; // transform to numbers int DayN=DayStr.GetInt(-1); int MonthN=MonthStr.GetInt(-1); int YearN=YearStr.GetInt(-1); if (MonthN == -1){ MonthN = TTmInfo::GetMonthN(MonthStr.ToCap()); } if ((DayN==-1)||(MonthN==-1)||(YearN==-1)){ return TSecTm(); } else { if (YearN<1000){ if (YearN<70){YearN+=2000;} else {YearN+=1900;}} // construct the date return GetDtTm(YearN, MonthN, DayN); } return TSecTm(); }
TSecTm TSecTm::GetDtTmFromHmsStr | ( | const TStr & | HmsStr | ) | [static] |
Definition at line 707 of file tm.cpp.
References AddHours(), AddMins(), AddSecs(), TChA::Clr(), TStr::GetInt(), GetZeroTm(), and TStr::Len().
{ int HmsStrLen=HmsStr.Len(); // hour TChA ChA; int ChN=0; while ((ChN<HmsStrLen)&&(HmsStr[ChN]!=':')){ChA+=HmsStr[ChN]; ChN++;} TStr HourStr=ChA; // minute ChA.Clr(); ChN++; while ((ChN<HmsStrLen)&&(HmsStr[ChN]!=':')){ChA+=HmsStr[ChN]; ChN++;} TStr MinStr=ChA; // second ChA.Clr(); ChN++; while (ChN<HmsStrLen){ChA+=HmsStr[ChN]; ChN++;} TStr SecStr=ChA; // transform to numbers int HourN=HourStr.GetInt(); int MinN=MinStr.GetInt(); int SecN=SecStr.GetInt(); // construct the time TSecTm Tm=TSecTm::GetZeroTm(); Tm.AddHours(HourN); Tm.AddMins(MinN); Tm.AddSecs(SecN); return Tm; }
TSecTm TSecTm::GetDtTmFromMdyHmsPmStr | ( | const TStr & | MdyHmsPmStr, |
const char & | DateSepCh = '/' , |
||
const char & | TimeSepCh = ':' |
||
) | [static] |
Definition at line 795 of file tm.cpp.
References AddHours(), AddMins(), AddSecs(), TChA::Clr(), Fail, GetDtTm(), TStr::GetInt(), TStr::IsInt(), and TStr::Len().
{ int MdyHmsPmStrLen=MdyHmsPmStr.Len(); // month TChA ChA; int ChN=0; while ((ChN<MdyHmsPmStrLen)&&(MdyHmsPmStr[ChN]!=DateSepCh)){ ChA+=MdyHmsPmStr[ChN]; ChN++;} TStr MonthStr=ChA; // day ChA.Clr(); ChN++; while ((ChN<MdyHmsPmStrLen)&&(MdyHmsPmStr[ChN]!=DateSepCh)){ ChA+=MdyHmsPmStr[ChN]; ChN++;} TStr DayStr=ChA; // year ChA.Clr(); ChN++; while ((ChN<MdyHmsPmStrLen)&&(MdyHmsPmStr[ChN]!=' ')){ ChA+=MdyHmsPmStr[ChN]; ChN++;} TStr YearStr=ChA; // hour ChA.Clr(); ChN++; while ((ChN<MdyHmsPmStrLen)&&(MdyHmsPmStr[ChN]!=TimeSepCh)){ ChA+=MdyHmsPmStr[ChN]; ChN++;} TStr HourStr=ChA; // minute ChA.Clr(); ChN++; while ((ChN<MdyHmsPmStrLen)&&(MdyHmsPmStr[ChN]!=TimeSepCh)){ ChA+=MdyHmsPmStr[ChN]; ChN++;} TStr MinStr=ChA; // second ChA.Clr(); ChN++; while ((ChN<MdyHmsPmStrLen)&&(MdyHmsPmStr[ChN]!=' ')){ ChA+=MdyHmsPmStr[ChN]; ChN++;} TStr SecStr=ChA; // AM/PM ChA.Clr(); ChN++; while (ChN<MdyHmsPmStrLen){ ChA+=MdyHmsPmStr[ChN]; ChN++;} TStr AmPmStr=ChA; // transform to numbers int MonthN=MonthStr.GetInt(); int DayN=DayStr.GetInt(); int YearN=YearStr.GetInt(); int HourN; int MinN; int SecN; if (HourStr.IsInt()){ HourN=HourStr.GetInt(); MinN=MinStr.GetInt(); SecN=SecStr.GetInt(); if (AmPmStr=="AM"){} else if (AmPmStr=="PM"){HourN+=12;} else {Fail;} } else { HourN=0; MinN=0; SecN=0; } // construct the time TSecTm Tm=TSecTm::GetDtTm(YearN, MonthN, DayN); Tm.AddHours(HourN); Tm.AddMins(MinN); Tm.AddSecs(SecN); return Tm; }
TSecTm TSecTm::GetDtTmFromMdyStr | ( | const TStr & | MdyStr | ) | [static] |
Definition at line 733 of file tm.cpp.
References TChA::Clr(), GetDtTm(), TStr::GetInt(), and TStr::Len().
{ int MdyStrLen=MdyStr.Len(); // month TChA ChA; int ChN=0; while ((ChN<MdyStrLen)&&(MdyStr[ChN]!='/')){ ChA+=MdyStr[ChN]; ChN++;} TStr MonthStr=ChA; // day ChA.Clr(); ChN++; while ((ChN<MdyStrLen)&&(MdyStr[ChN]!='/')){ ChA+=MdyStr[ChN]; ChN++;} TStr DayStr=ChA; // year ChA.Clr(); ChN++; while (ChN<MdyStrLen){ ChA+=MdyStr[ChN]; ChN++;} TStr YearStr=ChA; // transform to numbers int MonthN=MonthStr.GetInt(); int DayN=DayStr.GetInt(); int YearN=YearStr.GetInt(); if (YearN<1000){ if (YearN<70){YearN+=2000;} else {YearN+=1900;}} // construct the date return GetDtTm(YearN, MonthN, DayN); }
TSecTm 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] |
Definition at line 910 of file tm.cpp.
References TVec< TVal, TSizeTy >::Add(), TChA::CStr(), IAssert, TCh::IsNum(), and TSecTm().
{ TChA Tmp = YmdHmsPmStr; TVec<char *> FldV; // get the sequences of numbers for (char *c = (char *) Tmp.CStr(); *c; c++) { if (TCh::IsNum(*c)) { FldV.Add(c); while (TCh::IsNum(*c)) { c++; } c--; } else { *c = 0; } } const int Y = atoi(FldV[YearId]); const int M = atoi(FldV[MonId]); const int D = atoi(FldV[DayId]); const int H = atoi(FldV[HourId]); const int m = atoi(FldV[MinId]); const int S = atoi(FldV[SecId]); IAssert(Y>0 && M>0 && D>0 && M<13 && D<32); IAssert(H>=0 && H<24 && m>=0 && m<60 && S>=0 && S<60); return TSecTm(Y,M,D,H,m,S); }
TSecTm TSecTm::GetDtTmFromYmdHmsStr | ( | const TStr & | YmdHmsPmStr, |
const char & | DateSepCh = '-' , |
||
const char & | TimeSepCh = ':' |
||
) | [static] |
Definition at line 854 of file tm.cpp.
References AddHours(), AddMins(), AddSecs(), TChA::Clr(), GetDtTm(), TStr::GetInt(), TStr::IsInt(), and TStr::Len().
{ int YmdHmsPmStrLen=YmdHmsPmStr.Len(); // year TChA ChA; int ChN=0; while ((ChN<YmdHmsPmStrLen)&&(YmdHmsPmStr[ChN]!=DateSepCh)){ ChA+=YmdHmsPmStr[ChN]; ChN++;} TStr YearStr=ChA; // month ChA.Clr(); ChN++; while ((ChN<YmdHmsPmStrLen)&&(YmdHmsPmStr[ChN]!=DateSepCh)){ ChA+=YmdHmsPmStr[ChN]; ChN++;} TStr MonthStr=ChA; // day ChA.Clr(); ChN++; while ((ChN<YmdHmsPmStrLen)&&(YmdHmsPmStr[ChN]!=' ')){ ChA+=YmdHmsPmStr[ChN]; ChN++;} TStr DayStr=ChA; // hour ChA.Clr(); ChN++; while ((ChN<YmdHmsPmStrLen)&&(YmdHmsPmStr[ChN]!=TimeSepCh)){ ChA+=YmdHmsPmStr[ChN]; ChN++;} TStr HourStr=ChA; // minute ChA.Clr(); ChN++; while ((ChN<YmdHmsPmStrLen)&&(YmdHmsPmStr[ChN]!=TimeSepCh)){ ChA+=YmdHmsPmStr[ChN]; ChN++;} TStr MinStr=ChA; // second ChA.Clr(); ChN++; while (ChN<YmdHmsPmStrLen){ ChA+=YmdHmsPmStr[ChN]; ChN++;} TStr SecStr=ChA; // transform to numbers int MonthN=MonthStr.GetInt(); int DayN=DayStr.GetInt(); int YearN=YearStr.GetInt(); int HourN; int MinN; int SecN; if (HourStr.IsInt()){ HourN=HourStr.GetInt(); MinN=MinStr.GetInt(); SecN=SecStr.GetInt(); } else { HourN=0; MinN=0; SecN=0; } // construct the time TSecTm Tm=TSecTm::GetDtTm(YearN, MonthN, DayN); Tm.AddHours(HourN); Tm.AddMins(MinN); Tm.AddSecs(SecN); return Tm; }
TStr TSecTm::GetDtTmSortFNmStr | ( | ) | const |
Definition at line 545 of file tm.cpp.
References GetDayN(), GetHourN(), GetMinN(), GetMonthN(), GetSecN(), GetStr(), and GetYearN().
{ return TInt::GetStr(GetYearN(), "%04d")+"-"+ TInt::GetStr(GetMonthN(), "%02d")+"-"+ TInt::GetStr(GetDayN(), "%02d")+"_"+ TInt::GetStr(GetHourN(), "%02d")+"-"+ TInt::GetStr(GetMinN(), "%02d")+"-"+ TInt::GetStr(GetSecN(), "%02d"); }
TStr TSecTm::GetDtTmSortStr | ( | ) | const |
Definition at line 535 of file tm.cpp.
References GetDayN(), GetHourN(), GetMinN(), GetMonthN(), GetSecN(), GetStr(), and GetYearN().
{ return TInt::GetStr(GetYearN(), "%04d")+"/"+ TInt::GetStr(GetMonthN(), "%02d")+"/"+ TInt::GetStr(GetDayN(), "%02d")+" "+ TInt::GetStr(GetHourN(), "%02d")+":"+ TInt::GetStr(GetMinN(), "%02d")+":"+ TInt::GetStr(GetSecN(), "%02d"); }
TStr TSecTm::GetDtYmdStr | ( | ) | const |
Definition at line 502 of file tm.cpp.
References AbsSecs, TStr::Fmt(), GetTmStruct(), and IAssert.
{ struct tm Tm; IAssert(GetTmStruct(AbsSecs(), Tm)); return TStr::Fmt("%04d-%02d-%02d", Tm.tm_year+1900, Tm.tm_mon+1, Tm.tm_mday); }
int TSecTm::GetHourN | ( | ) | const |
Definition at line 591 of file tm.cpp.
References AbsSecs, GetTmStruct(), IAssert, and IsDef().
Referenced by GetDayPart(), GetDtTm(), GetDtTmSortFNmStr(), GetDtTmSortStr(), TGStat::GetHour(), GetStr(), and GetXmlTok().
{ struct tm Tm; IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm)); return Tm.tm_hour; }
uint TSecTm::GetInUnits | ( | const TTmUnit & | TmUnit | ) | const |
Definition at line 645 of file tm.cpp.
References AbsSecs, Fail, TJulianDate::GetJulianDateN(), GetTmStruct(), IAssert, IsDef(), TUInt::Mx, tmu10Min, tmu12Hour, tmu15Min, tmu1Hour, tmu1Min, tmu1Sec, tmu2Hour, tmu30Min, tmu4Hour, tmu6Hour, tmuDay, tmuMonth, tmuWeek, tmuYear, and TSecTm().
{ static const int DayZero = TJulianDate::GetJulianDateN(1, 1, 1970); if (TmUnit == tmu1Sec) { return AbsSecs; } struct tm Time; IAssert(IsDef() && GetTmStruct(AbsSecs(), Time)); switch (TmUnit) { case tmu1Min : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, Time.tm_min, 0).GetAbsSecs()/60; case tmu10Min : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, 10*(Time.tm_min/10), 0).GetAbsSecs()/(10*60); case tmu15Min : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, 15*(Time.tm_min/15), 0).GetAbsSecs()/(15*60); case tmu30Min : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, 30*(Time.tm_min/30), 0).GetAbsSecs()/(30*60); case tmu1Hour : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, 0, 0).GetAbsSecs()/3600; case tmu2Hour : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, 2*(Time.tm_hour/2), 0, 0).GetAbsSecs()/(2*3600); case tmu4Hour : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, 4*(Time.tm_hour/4), 0, 0).GetAbsSecs()/(4*3600); case tmu6Hour : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, 6*(Time.tm_hour/6), 0, 0).GetAbsSecs()/(6*3600); case tmu12Hour : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, 12*(Time.tm_hour/12), 0, 0).GetAbsSecs()/(12*3600); case tmuDay : return TJulianDate::GetJulianDateN(Time.tm_mday, Time.tm_mon+1, 1900+Time.tm_year) - DayZero; case tmuWeek : return (TJulianDate::GetJulianDateN(Time.tm_mday, Time.tm_mon+1, 1900+Time.tm_year)-DayZero)/7; case tmuMonth : return 12*(Time.tm_year-70)+Time.tm_mon+1; case tmuYear : return Time.tm_year+1900; default : Fail; } return TUInt::Mx; }
int TSecTm::GetMemUsed | ( | ) | const [inline] |
Definition at line 117 of file tm.h.
References AbsSecs, and TUInt::GetMemUsed().
{return AbsSecs.GetMemUsed();}
int TSecTm::GetMinN | ( | ) | const |
Definition at line 597 of file tm.cpp.
References AbsSecs, GetTmStruct(), IAssert, and IsDef().
Referenced by GetDtTm(), GetDtTmSortFNmStr(), GetDtTmSortStr(), TGStat::GetMin(), GetStr(), and GetXmlTok().
{ struct tm Tm; IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm)); return Tm.tm_min; }
int TSecTm::GetMonthN | ( | ) | const |
Definition at line 561 of file tm.cpp.
References AbsSecs, GetTmStruct(), IAssert, and IsDef().
Referenced by GetDtTmFromDmyStr(), GetDtTmSortFNmStr(), GetDtTmSortStr(), TGStat::GetMonth(), GetStr(), and GetXmlTok().
{ struct tm Tm; IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm)); return Tm.tm_mon+1; }
TStr TSecTm::GetMonthNm | ( | const TLoc & | Loc = lUs | ) | const |
Definition at line 567 of file tm.cpp.
References AbsSecs, GetTmStruct(), IAssert, and IsDef().
Referenced by GetDtStr(), and GetStr().
{ struct tm Tm; IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm)); return TTmInfo::GetMonthNm(Tm.tm_mon+1, Loc); }
int TSecTm::GetPrimHashCd | ( | ) | const [inline] |
Definition at line 119 of file tm.h.
References AbsSecs, and TUInt::GetPrimHashCd().
{return AbsSecs.GetPrimHashCd();}
int TSecTm::GetSecHashCd | ( | ) | const [inline] |
Definition at line 120 of file tm.h.
References AbsSecs, and TUInt::GetSecHashCd().
{return AbsSecs.GetSecHashCd();}
int TSecTm::GetSecN | ( | ) | const |
Definition at line 603 of file tm.cpp.
References AbsSecs, GetTmStruct(), IAssert, and IsDef().
Referenced by GetDtTm(), GetDtTmSortFNmStr(), GetDtTmSortStr(), TGStat::GetSec(), GetStr(), and GetXmlTok().
{ struct tm Tm; IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm)); return Tm.tm_sec; }
TStr TSecTm::GetStr | ( | const TLoc & | Loc = lUs | ) | const |
Definition at line 457 of file tm.cpp.
References AbsSecs, TStr::CStr(), TStr::Fmt(), TTmInfo::GetDayOfWeekNm(), GetMonthNm(), GetTmStruct(), IAssert, and IsDef().
Referenced by TTimeNENet::DumpTimeStat(), GetDtTmSortFNmStr(), GetDtTmSortStr(), GetStr(), TGStat::GetTmStr(), TTimeNENet::LoadEdgeTm(), TTimeNENet::LoadFlickr(), TTimeNet::PlotMissingPast(), and TTimeNENet::PlotMissingPast().
{ if (IsDef()) { struct tm Tm; IAssert(GetTmStruct(AbsSecs(), Tm)); // Wed May 14 15:30:17 2003 return TStr::Fmt("%s %s %d %02d:%02d:%02d %d", TTmInfo::GetDayOfWeekNm(Tm.tm_wday + 1, Loc).CStr(), TTmInfo::GetMonthNm(Tm.tm_mon + 1, Loc).CStr(), Tm.tm_mday, Tm.tm_hour, Tm.tm_min, Tm.tm_sec, Tm.tm_year+1900); } else { return "Undef"; } }
TStr TSecTm::GetStr | ( | const TTmUnit & | TmUnit | ) | const |
Definition at line 471 of file tm.cpp.
References TStr::Fmt(), GetDayN(), GetHourN(), GetMinN(), GetMonthN(), GetSecN(), GetStr(), GetYearN(), tmuDay, tmuMonth, and tmuYear.
{ if (TmUnit == tmuYear) { return TInt::GetStr(GetYearN()); } else if (TmUnit == tmuMonth) { return TStr::Fmt("%04d-%02d", GetYearN(), GetMonthN()); } else if (TmUnit == tmuDay) { return TStr::Fmt("%04d-%02d-%02d", GetYearN(), GetMonthN(), GetDayN()); } else { return TStr::Fmt("%04d-%02d-%02d %02d:%02d:%02d", GetYearN(), GetMonthN(), GetDayN(), GetHourN(), GetMinN(), GetSecN()); } }
TStr TSecTm::GetTmMinStr | ( | ) | const |
Definition at line 525 of file tm.cpp.
References AbsSecs, TStr::Fmt(), GetTmStruct(), IAssert, and IsDef().
{ if (IsDef()){ struct tm Tm; IAssert(GetTmStruct(AbsSecs(), Tm)); return TStr::Fmt("%02d:%02d", Tm.tm_min, Tm.tm_sec); } else { return "Undef"; } }
bool TSecTm::GetTmSec | ( | const int & | YearN, |
const int & | MonthN, | ||
const int & | DayN, | ||
const int & | HourN, | ||
const int & | MinN, | ||
const int & | SecN, | ||
uint & | AbsSec | ||
) | [static, private] |
Definition at line 363 of file tm.cpp.
Referenced by GetCurTm(), GetDtTm(), and TSecTm().
{ AbsSec = 0; // tm_isdst: // - Positive if daylight saving time is in effect; // - 0 if daylight saving time is not in effect; // - negative if status of daylight saving time is unknown. // The C run-time library assumes the United States's rules for implementing // the calculation of Daylight Saving Time (DST). struct tm Tm; Tm.tm_year=YearN-1900; Tm.tm_mon=MonthN-1; Tm.tm_mday=DayN; Tm.tm_hour=HourN; Tm.tm_min=MinN; Tm.tm_sec=SecN; Tm.tm_wday=1; Tm.tm_yday=1; Tm.tm_isdst=-1; return TSecTm::GetTmSec(Tm, AbsSec); }
bool TSecTm::GetTmSec | ( | struct tm & | Tm, |
uint & | AbsSec | ||
) | [static, private] |
Definition at line 407 of file tm.cpp.
References TStr::CStr(), EAssertR, TStr::Fmt(), MkGmTime(), and TUInt::Mx.
{ const time_t GmtTime = MkGmTime(&Tm); EAssertR(uint(GmtTime) < TUInt::Mx, TStr::Fmt("Time out of range: %d/%d/%d %02d:%02d:%02d", Tm.tm_year, Tm.tm_mon, Tm.tm_mday, Tm.tm_hour, Tm.tm_min, Tm.tm_sec).CStr()); AbsSec = uint(GmtTime); return GmtTime >= 0; }
TStr TSecTm::GetTmStr | ( | ) | const |
Definition at line 515 of file tm.cpp.
References AbsSecs, TStr::Fmt(), GetTmStruct(), IAssert, and IsDef().
{ if (IsDef()){ struct tm Tm; IAssert(GetTmStruct(AbsSecs(), Tm)); return TStr::Fmt("%02d:%02d:%02d", Tm.tm_hour, Tm.tm_min, Tm.tm_sec); } else { return "Undef"; } }
bool TSecTm::GetTmStruct | ( | const uint & | AbsSec, |
struct tm & | Tm | ||
) | [static, private] |
Definition at line 416 of file tm.cpp.
Referenced by GetComps(), GetDayN(), GetDayOfWeekN(), GetDayOfWeekNm(), GetDtMdyStr(), GetDtStr(), GetDtYmdStr(), GetHourN(), GetInUnits(), GetMinN(), GetMonthN(), GetMonthNm(), GetSecN(), GetStr(), GetTmMinStr(), GetTmStr(), GetYearN(), GetYmdTmStr(), and Round().
{ const time_t TimeT = time_t(AbsSec); #if defined(GLib_MSC) return _gmtime64_s(&Tm, &TimeT) == 0; #elif defined(GLib_BCB) Tm=*gmtime(&TimeT); return true; #else return gmtime_r(&TimeT, &Tm) != NULL; #endif }
PXmlTok TSecTm::GetXmlTok | ( | ) | const |
Definition at line 446 of file tm.cpp.
References TXmlTok::AddArg(), GetDayN(), GetHourN(), GetMinN(), GetMonthN(), GetSecN(), GetYearN(), and TXmlTok::New().
{ PXmlTok NodeTok = TXmlTok::New("NodeTime"); NodeTok->AddArg("Year", GetYearN()); NodeTok->AddArg("Month", GetMonthN()); NodeTok->AddArg("Day", GetDayN()); NodeTok->AddArg("Hour", GetHourN()); NodeTok->AddArg("Min", GetMinN()); NodeTok->AddArg("Sec", GetSecN()); return NodeTok; }
int TSecTm::GetYearN | ( | ) | const |
Definition at line 555 of file tm.cpp.
References AbsSecs, GetTmStruct(), IAssert, and IsDef().
Referenced by GetDtTmSortFNmStr(), GetDtTmSortStr(), GetStr(), GetXmlTok(), and TGStat::GetYear().
{ struct tm Tm; IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm)); return Tm.tm_year+1900; }
TStr TSecTm::GetYmdTmStr | ( | ) | const |
Definition at line 508 of file tm.cpp.
References AbsSecs, TStr::Fmt(), GetTmStruct(), and IAssert.
{ struct tm Tm; IAssert(GetTmStruct(AbsSecs(), Tm)); return TStr::Fmt("%04d-%02d-%02d %02d:%02d:%02d", Tm.tm_year+1900, Tm.tm_mon+1, Tm.tm_mday, Tm.tm_hour, Tm.tm_min, Tm.tm_sec); }
static TSecTm TSecTm::GetZeroTm | ( | ) | [inline, static] |
Definition at line 186 of file tm.h.
References TSecTm().
Referenced by GetDtTmFromHmsStr(), and GetZeroWeekTm().
{return TSecTm(0).AddHours(23);}
TSecTm TSecTm::GetZeroWeekTm | ( | ) | [static] |
Definition at line 685 of file tm.cpp.
References AddDays(), GetDayOfWeekN(), GetZeroTm(), and TTmInfo::MonN.
{ TSecTm ZeroWeekTm=GetZeroTm(); while (ZeroWeekTm.GetDayOfWeekN()!=TTmInfo::MonN){ ZeroWeekTm.AddDays(1);} return ZeroWeekTm; }
bool TSecTm::IsDef | ( | ) | const [inline] |
Definition at line 123 of file tm.h.
References AbsSecs, and TUInt::Mx.
Referenced by AddDays(), AddHours(), AddMins(), AddSecs(), AddWeeks(), TTimeNENet::DumpTimeStat(), GetComps(), GetDayN(), GetDayOfWeekN(), GetDayOfWeekNm(), GetDSecs(), GetDtStr(), TTimeNENet::GetGraphUpToTm(), GetHourN(), GetInUnits(), GetMinN(), GetMonthN(), GetMonthNm(), GetSecN(), GetStr(), GetTmMinStr(), GetTmStr(), GetYearN(), TGStat::HasVal(), operator+=(), operator-=(), operator<(), TTimeNet::PlotMissingPast(), Round(), TTimeNENet::SetNodeTmToFirstEdgeTm(), SubDays(), SubHours(), SubMins(), SubSecs(), SubWeeks(), and TTimeNENet::UpdateNodeTimes().
void TSecTm::Load | ( | TSIn & | SIn | ) | [inline] |
TSecTm TSecTm::LoadTxt | ( | TILx & | Lx | ) | [static] |
Definition at line 945 of file tm.cpp.
References TILx::GetInt(), and TSecTm().
Referenced by TILx::GetVarSecTm().
time_t TSecTm::MkGmTime | ( | struct tm * | t | ) | [static, private] |
Definition at line 380 of file tm.cpp.
Referenced by GetTmSec().
{ static const int m_to_d[12] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}; short month, year; time_t result; month = t->tm_mon; year = t->tm_year + month / 12 + 1900; month %= 12; if (month < 0) { year -= 1; month += 12; } result = (year - 1970) * 365 + (year - 1969) / 4 + m_to_d[month]; result = (year - 1970) * 365 + m_to_d[month]; if (month <= 1) { year -= 1; } result += (year - 1968) / 4; result -= (year - 1900) / 100; result += (year - 1600) / 400; result += t->tm_mday; result -= 1; result *= 24; result += t->tm_hour; result *= 60; result += t->tm_min; result *= 60; result += t->tm_sec; return result; }
TSecTm::operator uint | ( | ) | const [inline] |
bool TSecTm::operator< | ( | const TSecTm & | SecTm | ) | const [inline] |
bool TSecTm::operator== | ( | const TSecTm & | SecTm | ) | const [inline] |
TSecTm TSecTm::Round | ( | const TTmUnit & | TmUnit | ) | const |
Definition at line 620 of file tm.cpp.
References AbsSecs, Fail, TJulianDate::GetCalendarDate(), TJulianDate::GetJulianDateN(), GetTmStruct(), IAssert, IsDef(), tmu10Min, tmu12Hour, tmu15Min, tmu1Hour, tmu1Min, tmu1Sec, tmu2Hour, tmu30Min, tmu4Hour, tmu6Hour, tmuDay, tmuMonth, tmuWeek, tmuYear, and TSecTm().
Referenced by TTimeNENet::GetEdgeTmBuckets(), and TTimeNENet::GetTmBuckets().
{ if (TmUnit == tmu1Sec) { return *this; } struct tm Time; IAssert(IsDef() && GetTmStruct(AbsSecs(), Time)); switch (TmUnit) { case tmu1Min : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, Time.tm_min, 0); case tmu10Min : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, 10*(Time.tm_min/10), 0); case tmu15Min : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, 15*(Time.tm_min/15), 0); case tmu30Min : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, 30*(Time.tm_min/30), 0); case tmu1Hour : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, 0, 0); case tmu2Hour : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, 2*(Time.tm_hour/2), 0, 0); case tmu4Hour : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, 4*(Time.tm_hour/4), 0, 0); case tmu6Hour : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, 6*(Time.tm_hour/6), 0, 0); case tmu12Hour : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, 12*(Time.tm_hour/12), 0, 0); case tmuDay : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, 0, 0, 0); case tmuMonth : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, 1, 0, 0, 0); case tmuYear : return TSecTm(Time.tm_year+1900, 1, 1, 0, 0, 0); case tmuWeek : { int dd=1, mm=1, yy=1; // week starts on Thursday, since 1.1.1970 is Thursday const int Day = TJulianDate::GetJulianDateN(Time.tm_mday, Time.tm_mon+1, 1900+Time.tm_year); TJulianDate::GetCalendarDate(3+7*(Day/7), dd, mm, yy); return TSecTm(yy, mm, dd, 0, 0, 0); } default : Fail; } return TSecTm(); }
void TSecTm::Save | ( | TSOut & | SOut | ) | const [inline] |
Definition at line 103 of file tm.h.
References AbsSecs, and TUInt::Save().
Referenced by TGStat::Save().
void TSecTm::SaveTxt | ( | TOLx & | Lx | ) | const |
TSecTm& TSecTm::SubDays | ( | const int & | Days | ) | [inline] |
TSecTm& TSecTm::SubHours | ( | const int & | Hours | ) | [inline] |
TSecTm& TSecTm::SubMins | ( | const int & | Mins | ) | [inline] |
TSecTm& TSecTm::SubSecs | ( | const int & | Secs | ) | [inline] |
TSecTm& TSecTm::SubWeeks | ( | const int & | Weeks | ) | [inline] |
void TSecTm::Undef | ( | ) | [inline] |
TUInt TSecTm::AbsSecs [private] |
Definition at line 83 of file tm.h.
Referenced by AddDays(), AddHours(), AddMins(), AddSecs(), AddWeeks(), GetAbsSecs(), GetComps(), GetDayN(), GetDayOfWeekN(), GetDayOfWeekNm(), GetDSecs(), GetDtMdyStr(), GetDtStr(), GetDtTm(), GetDtYmdStr(), GetHourN(), GetInUnits(), GetMemUsed(), GetMinN(), GetMonthN(), GetMonthNm(), GetPrimHashCd(), GetSecHashCd(), GetSecN(), GetStr(), GetTmMinStr(), GetTmStr(), GetYearN(), GetYmdTmStr(), IsDef(), Load(), operator uint(), operator+=(), operator-=(), operator<(), operator=(), operator==(), Round(), Save(), SaveTxt(), SubDays(), SubHours(), SubMins(), SubSecs(), SubWeeks(), TSecTm(), and Undef().