|
SNAP Library 2.0, User 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] |
| 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 |
||
| ) |
| TSecTm::TSecTm | ( | const TTm & | Tm | ) |
| TSecTm::TSecTm | ( | const PXmlTok & | XmlTok | ) | [explicit] |
Definition at line 436 of file tm.cpp.
{
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] |
| TSecTm& TSecTm::AddMins | ( | const int & | Mins | ) | [inline] |
| TSecTm& TSecTm::AddSecs | ( | const int & | Secs | ) | [inline] |
| TSecTm& TSecTm::AddWeeks | ( | const int & | Weeks | ) | [inline] |
| uint TSecTm::GetAbsSecs | ( | ) | const [inline] |
| void TSecTm::GetComps | ( | int & | Year, |
| int & | Month, | ||
| int & | Day, | ||
| int & | Hour, | ||
| int & | Min, | ||
| int & | Sec | ||
| ) | const |
| static TSecTm TSecTm::GetCurDtTm | ( | ) | [inline, static] |
| TSecTm TSecTm::GetCurTm | ( | ) | [static] |
Definition at line 692 of file tm.cpp.
{
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 |
| int TSecTm::GetDayOfWeekN | ( | ) | const |
| TStr TSecTm::GetDayOfWeekNm | ( | const TLoc & | Loc = lUs | ) | const |
Definition at line 585 of file tm.cpp.
{
struct tm Tm;
IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
return TTmInfo::GetDayOfWeekNm(Tm.tm_wday+1, Loc);
}
| TStr TSecTm::GetDayPart | ( | ) | const |
| uint TSecTm::GetDSecs | ( | const TSecTm & | SecTm1, |
| const TSecTm & | SecTm2 | ||
| ) | [static] |
| TStr TSecTm::GetDtMdyStr | ( | ) | const |
| TStr TSecTm::GetDtStr | ( | const TLoc & | Loc = lUs | ) | const |
Definition at line 484 of file tm.cpp.
{
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] |
| TSecTm TSecTm::GetDtTm | ( | const TSecTm & | Tm | ) | [static] |
| TSecTm TSecTm::GetDtTmFromDmyStr | ( | const TStr & | DmyStr | ) | [static] |
Definition at line 761 of file tm.cpp.
{
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.
{
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.
{
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.
{
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.
{
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.
{
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.
{
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.
{
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 |
| int TSecTm::GetHourN | ( | ) | const |
| uint TSecTm::GetInUnits | ( | const TTmUnit & | TmUnit | ) | const |
Definition at line 645 of file tm.cpp.
{
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.
{return AbsSecs.GetMemUsed();}
| int TSecTm::GetMinN | ( | ) | const |
| int TSecTm::GetMonthN | ( | ) | const |
| TStr TSecTm::GetMonthNm | ( | const TLoc & | Loc = lUs | ) | const |
Definition at line 567 of file tm.cpp.
{
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.
{return AbsSecs.GetPrimHashCd();}
| int TSecTm::GetSecHashCd | ( | ) | const [inline] |
Definition at line 120 of file tm.h.
{return AbsSecs.GetSecHashCd();}
| int TSecTm::GetSecN | ( | ) | const |
| TStr TSecTm::GetStr | ( | const TLoc & | Loc = lUs | ) | const |
Definition at line 457 of file tm.cpp.
{
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.
{
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 |
| 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.
{
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] |
| TStr TSecTm::GetTmStr | ( | ) | const |
| bool TSecTm::GetTmStruct | ( | const uint & | AbsSec, |
| struct tm & | Tm | ||
| ) | [static, private] |
| PXmlTok TSecTm::GetXmlTok | ( | ) | const |
| int TSecTm::GetYearN | ( | ) | const |
| TStr TSecTm::GetYmdTmStr | ( | ) | const |
| static TSecTm TSecTm::GetZeroTm | ( | ) | [inline, static] |
| TSecTm TSecTm::GetZeroWeekTm | ( | ) | [static] |
Definition at line 685 of file tm.cpp.
{
TSecTm ZeroWeekTm=GetZeroTm();
while (ZeroWeekTm.GetDayOfWeekN()!=TTmInfo::MonN){
ZeroWeekTm.AddDays(1);}
return ZeroWeekTm;
}
| bool TSecTm::IsDef | ( | ) | const [inline] |
| TSecTm TSecTm::LoadTxt | ( | TILx & | Lx | ) | [static] |
| time_t TSecTm::MkGmTime | ( | struct tm * | t | ) | [static, private] |
Definition at line 380 of file tm.cpp.
{
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;
}
| 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.
{
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] |
| 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] |