SNAP Library 2.1, User Reference  2013-09-25 10:47:25
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
TSecTm Class Reference

#include <tm.h>

List of all members.

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
TSecTmoperator= (const TSecTm &SecTm)
TSecTmoperator= (const uint &_AbsSecs)
TSecTmoperator+= (const uint &Secs)
TSecTmoperator-= (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
TSecTmAddSecs (const int &Secs)
TSecTmSubSecs (const int &Secs)
TSecTmAddMins (const int &Mins)
TSecTmSubMins (const int &Mins)
TSecTmAddHours (const int &Hours)
TSecTmSubHours (const int &Hours)
TSecTmAddDays (const int &Days)
TSecTmSubDays (const int &Days)
TSecTmAddWeeks (const int &Weeks)
TSecTmSubWeeks (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

Detailed Description

Definition at line 81 of file tm.h.


Constructor & Destructor Documentation

TSecTm::TSecTm ( ) [inline]

Definition at line 92 of file tm.h.

TSecTm::TSecTm ( const uint _AbsSecs) [inline, explicit]

Definition at line 93 of file tm.h.

: AbsSecs(_AbsSecs){}
TSecTm::TSecTm ( const TSecTm SecTm) [inline]

Definition at line 95 of file tm.h.

: AbsSecs(SecTm.AbsSecs){}
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.

                                                     : AbsSecs(TUInt::Mx){
  GetTmSec(YearN, MonthN, DayN, HourN, MinN, SecN, AbsSecs.Val);
}
TSecTm::TSecTm ( const TTm Tm)

Definition at line 432 of file tm.cpp.

                           : AbsSecs(
 TSecTm(Tm.GetYear(), Tm.GetMonth(), Tm.GetDay(), Tm.GetHour(),
   Tm.GetMin(), Tm.GetSec()).GetAbsSecs()) { }
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]

Definition at line 101 of file tm.h.

: AbsSecs(SIn){}

Member Function Documentation

TSecTm& TSecTm::AddDays ( const int &  Days) [inline]

Definition at line 167 of file tm.h.

                                  {
    IAssert(IsDef()); AbsSecs.Val+=uint(Days*24*3600); return *this;}
TSecTm& TSecTm::AddHours ( const int &  Hours) [inline]

Definition at line 163 of file tm.h.

                                    {
    IAssert(IsDef()); AbsSecs.Val+=uint(Hours*3600); return *this;}
TSecTm& TSecTm::AddMins ( const int &  Mins) [inline]

Definition at line 159 of file tm.h.

                                  {
    IAssert(IsDef()); AbsSecs.Val+=uint(Mins*60); return *this;}
TSecTm& TSecTm::AddSecs ( const int &  Secs) [inline]

Definition at line 155 of file tm.h.

                                  {
    IAssert(IsDef()); AbsSecs.Val+=uint(Secs); return *this;}
TSecTm& TSecTm::AddWeeks ( const int &  Weeks) [inline]

Definition at line 171 of file tm.h.

                                    {
    IAssert(IsDef()); AbsSecs.Val+=uint(Weeks*7*24*3600); return *this;}
uint TSecTm::GetAbsSecs ( ) const [inline]

Definition at line 149 of file tm.h.

{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.

                                                                                          {
  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]

Definition at line 189 of file tm.h.

{return GetDtTm(GetCurTm());}
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

Definition at line 573 of file tm.cpp.

                          {
  struct tm Tm;
  IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
  return Tm.tm_mday;
}
int TSecTm::GetDayOfWeekN ( ) const

Definition at line 579 of file tm.cpp.

                                {
  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.

                                                 {
  struct tm Tm;
  IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
  return TTmInfo::GetDayOfWeekNm(Tm.tm_wday+1, Loc);
}

Definition at line 669 of file tm.cpp.

                              {
  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]

Definition at line 678 of file tm.cpp.

                                                               {
  IAssert(SecTm1.IsDef()&&SecTm2.IsDef());
  const time_t Time1= time_t(SecTm1.AbsSecs());
  const time_t Time2= time_t(SecTm2.AbsSecs());
  return uint(difftime(Time2, Time1));
}

Definition at line 496 of file tm.cpp.

                               {
  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.

                                           {
  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.

                                                                          {
  uint AbsSecs;
  TSecTm::GetTmSec(YearN, MonthN, DayN, 0, 0, 0, AbsSecs);
  return TSecTm(AbsSecs);
}
TSecTm TSecTm::GetDtTm ( const TSecTm Tm) [static]

Definition at line 939 of file tm.cpp.

                                      {
  int DaySecs=Tm.GetHourN()*3600+Tm.GetMinN()*60+Tm.GetSecN();
  TSecTm DtTm(Tm.AbsSecs-DaySecs);
  return DtTm;
}
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;
}

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");
}

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");
}

Definition at line 502 of file tm.cpp.

                               {
  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.

                           {
  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.

                                                   {
  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

Definition at line 597 of file tm.cpp.

                          {
  struct tm Tm;
  IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
  return Tm.tm_min;
}
int TSecTm::GetMonthN ( ) const

Definition at line 561 of file tm.cpp.

                            {
  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.

                                             {
  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

Definition at line 603 of file tm.cpp.

                          {
  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.

                                         {
  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());
  }
}

Definition at line 525 of file tm.cpp.

                               {
  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.

                                                                                                                                            {
  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.

                                                 {
  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;
}

Definition at line 515 of file tm.cpp.

                            {
  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.

                                                          {
  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
}

Definition at line 446 of file tm.cpp.

                                {
  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.

                           {
  struct tm Tm;
  IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
  return Tm.tm_year+1900;
}

Definition at line 508 of file tm.cpp.

                               {
  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.

{return TSecTm(0).AddHours(23);}

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]

Definition at line 123 of file tm.h.

{return uint(AbsSecs)!=TUInt::Mx;}
void TSecTm::Load ( TSIn SIn) [inline]

Definition at line 102 of file tm.h.

{AbsSecs.Load(SIn);}
TSecTm TSecTm::LoadTxt ( TILx Lx) [static]

Definition at line 945 of file tm.cpp.

                              {
  return TSecTm(Lx.GetInt());
}
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;
}
TSecTm::operator uint ( ) const [inline]

Definition at line 94 of file tm.h.

{return AbsSecs.Val;}
TSecTm& TSecTm::operator+= ( const uint Secs) [inline]

Definition at line 109 of file tm.h.

                                      {
    IAssert(IsDef()); AbsSecs()+=Secs; return *this;}
TSecTm& TSecTm::operator-= ( const uint Secs) [inline]

Definition at line 111 of file tm.h.

                                      {
    IAssert(IsDef()); AbsSecs()-=Secs; return *this;}
bool TSecTm::operator< ( const TSecTm SecTm) const [inline]

Definition at line 115 of file tm.h.

                                            {
    IAssert(IsDef()&&SecTm.IsDef()); return AbsSecs<SecTm.AbsSecs;}
TSecTm& TSecTm::operator= ( const TSecTm SecTm) [inline]

Definition at line 105 of file tm.h.

                                        {
    AbsSecs=SecTm.AbsSecs; return *this;}
TSecTm& TSecTm::operator= ( const uint _AbsSecs) [inline]

Definition at line 107 of file tm.h.

                                         {
    AbsSecs=_AbsSecs; return *this;}
bool TSecTm::operator== ( const TSecTm SecTm) const [inline]

Definition at line 113 of file tm.h.

                                             {
    return AbsSecs==SecTm.AbsSecs;}
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]

Definition at line 103 of file tm.h.

{AbsSecs.Save(SOut);}
void TSecTm::SaveTxt ( TOLx Lx) const

Definition at line 949 of file tm.cpp.

                                   {
  IAssert(int(AbsSecs) < TInt::Mx);
  Lx.PutInt((int)AbsSecs);
}
TSecTm& TSecTm::SubDays ( const int &  Days) [inline]

Definition at line 169 of file tm.h.

                                  {
    IAssert(IsDef() && uint(Days*24*3600) < AbsSecs); AbsSecs.Val-=uint(Days*24*3600); return *this;}
TSecTm& TSecTm::SubHours ( const int &  Hours) [inline]

Definition at line 165 of file tm.h.

                                    {
    IAssert(IsDef() && uint(Hours*3600) < AbsSecs); AbsSecs.Val-=uint(Hours*3600); return *this;}
TSecTm& TSecTm::SubMins ( const int &  Mins) [inline]

Definition at line 161 of file tm.h.

                                  {
    IAssert(IsDef() && uint(Mins*60) < AbsSecs); AbsSecs.Val-=uint(Mins*60); return *this;}
TSecTm& TSecTm::SubSecs ( const int &  Secs) [inline]

Definition at line 157 of file tm.h.

                                  {
    IAssert(IsDef() && uint(Secs) < AbsSecs); AbsSecs.Val-=uint(Secs); return *this;}
TSecTm& TSecTm::SubWeeks ( const int &  Weeks) [inline]

Definition at line 173 of file tm.h.

                                    {
    IAssert(IsDef() && uint(Weeks*7*24*3600) < AbsSecs); AbsSecs.Val-=uint(Weeks*7*24*3600); return *this;}
void TSecTm::Undef ( ) [inline]

Definition at line 124 of file tm.h.


Member Data Documentation

Definition at line 83 of file tm.h.


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