SNAP Library 2.4, User Reference  2015-05-11 19:40:56
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TSecTm Class Reference

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

92 : AbsSecs(TUInt::Mx){}
static const uint Mx
Definition: dt.h:1152
TUInt AbsSecs
Definition: tm.h:83
TSecTm::TSecTm ( const uint _AbsSecs)
inlineexplicit

Definition at line 93 of file tm.h.

93 : AbsSecs(_AbsSecs){}
TUInt AbsSecs
Definition: tm.h:83
TSecTm::TSecTm ( const TSecTm SecTm)
inline

Definition at line 95 of file tm.h.

95 : AbsSecs(SecTm.AbsSecs){}
TUInt AbsSecs
Definition: tm.h:83
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.

428  : AbsSecs(TUInt::Mx){
429  GetTmSec(YearN, MonthN, DayN, HourN, MinN, SecN, AbsSecs.Val);
430 }
static const uint Mx
Definition: dt.h:1152
static bool GetTmSec(const int &YearN, const int &MonthN, const int &DayN, const int &HourN, const int &MinN, const int &SecN, uint &AbsSec)
Definition: tm.cpp:363
TUInt AbsSecs
Definition: tm.h:83
uint Val
Definition: dt.h:1149
TSecTm::TSecTm ( const TTm Tm)

Definition at line 432 of file tm.cpp.

432  : AbsSecs(
433  TSecTm(Tm.GetYear(), Tm.GetMonth(), Tm.GetDay(), Tm.GetHour(),
434  Tm.GetMin(), Tm.GetSec()).GetAbsSecs()) { }
int GetMin() const
Definition: tm.h:281
int GetMonth() const
Definition: tm.h:275
int GetHour() const
Definition: tm.h:280
TSecTm()
Definition: tm.h:92
int GetYear() const
Definition: tm.h:274
int GetDay() const
Definition: tm.h:277
uint GetAbsSecs() const
Definition: tm.h:149
TUInt AbsSecs
Definition: tm.h:83
int GetSec() const
Definition: tm.h:282
TSecTm::TSecTm ( const PXmlTok XmlTok)
explicit

Definition at line 436 of file tm.cpp.

436  {
437  const int Year = XmlTok->GetIntArgVal("Year");
438  const int Month = XmlTok->GetIntArgVal("Month");
439  const int Day = XmlTok->GetIntArgVal("Day");
440  const int Hour = XmlTok->GetIntArgVal("Hour");
441  const int Min = XmlTok->GetIntArgVal("Min");
442  const int Sec = XmlTok->GetIntArgVal("Sec");
443  AbsSecs = TSecTm(Year, Month, Day, Hour, Min, Sec).GetAbsSecs();
444 }
TSecTm()
Definition: tm.h:92
TUInt AbsSecs
Definition: tm.h:83
TSecTm::TSecTm ( TSIn SIn)
inline

Definition at line 101 of file tm.h.

101 : AbsSecs(SIn){}
TUInt AbsSecs
Definition: tm.h:83

Member Function Documentation

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

Definition at line 167 of file tm.h.

167  {
168  IAssert(IsDef()); AbsSecs.Val+=uint(Days*24*3600); return *this;}
#define IAssert(Cond)
Definition: bd.h:262
bool IsDef() const
Definition: tm.h:123
unsigned int uint
Definition: bd.h:11
TUInt AbsSecs
Definition: tm.h:83
uint Val
Definition: dt.h:1149
TSecTm& TSecTm::AddHours ( const int &  Hours)
inline

Definition at line 163 of file tm.h.

163  {
164  IAssert(IsDef()); AbsSecs.Val+=uint(Hours*3600); return *this;}
#define IAssert(Cond)
Definition: bd.h:262
bool IsDef() const
Definition: tm.h:123
unsigned int uint
Definition: bd.h:11
TUInt AbsSecs
Definition: tm.h:83
uint Val
Definition: dt.h:1149
TSecTm& TSecTm::AddMins ( const int &  Mins)
inline

Definition at line 159 of file tm.h.

159  {
160  IAssert(IsDef()); AbsSecs.Val+=uint(Mins*60); return *this;}
#define IAssert(Cond)
Definition: bd.h:262
bool IsDef() const
Definition: tm.h:123
unsigned int uint
Definition: bd.h:11
TUInt AbsSecs
Definition: tm.h:83
uint Val
Definition: dt.h:1149
TSecTm& TSecTm::AddSecs ( const int &  Secs)
inline

Definition at line 155 of file tm.h.

155  {
156  IAssert(IsDef()); AbsSecs.Val+=uint(Secs); return *this;}
#define IAssert(Cond)
Definition: bd.h:262
bool IsDef() const
Definition: tm.h:123
unsigned int uint
Definition: bd.h:11
TUInt AbsSecs
Definition: tm.h:83
uint Val
Definition: dt.h:1149
TSecTm& TSecTm::AddWeeks ( const int &  Weeks)
inline

Definition at line 171 of file tm.h.

171  {
172  IAssert(IsDef()); AbsSecs.Val+=uint(Weeks*7*24*3600); return *this;}
#define IAssert(Cond)
Definition: bd.h:262
bool IsDef() const
Definition: tm.h:123
unsigned int uint
Definition: bd.h:11
TUInt AbsSecs
Definition: tm.h:83
uint Val
Definition: dt.h:1149
uint TSecTm::GetAbsSecs ( ) const
inline

Definition at line 149 of file tm.h.

149 {return AbsSecs();}
TUInt AbsSecs
Definition: tm.h:83
void TSecTm::GetComps ( int &  Year,
int &  Month,
int &  Day,
int &  Hour,
int &  Min,
int &  Sec 
) const

Definition at line 609 of file tm.cpp.

609  {
610  struct tm Tm;
611  EAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
612  Year = Tm.tm_year+1900;
613  Month = Tm.tm_mon+1;
614  Day = Tm.tm_mday;
615  Hour = Tm.tm_hour;
616  Min = Tm.tm_min;
617  Sec = Tm.tm_sec;
618 }
bool IsDef() const
Definition: tm.h:123
#define EAssert(Cond)
Definition: bd.h:280
TUInt AbsSecs
Definition: tm.h:83
static bool GetTmStruct(const uint &AbsSec, struct tm &Tm)
Definition: tm.cpp:416
static TSecTm TSecTm::GetCurDtTm ( )
inlinestatic

Definition at line 189 of file tm.h.

189 {return GetDtTm(GetCurTm());}
static TSecTm GetDtTm(const int &YearN, const int &MonthN, const int &DayN)
Definition: tm.cpp:933
static TSecTm GetCurTm()
Definition: tm.cpp:692
TSecTm TSecTm::GetCurTm ( )
static

Definition at line 692 of file tm.cpp.

692  {
693  const time_t TmSec = time(NULL);
694  struct tm LocTm;
695  uint AbsSec = TUInt::Mx;
696  #if defined(GLib_MSN)
697  localtime_s(&LocTm, &TmSec);
698  #elif defined(GLib_BCB)
699  LocTm = *localtime(&TmSec);
700  #else
701  LocTm = *localtime(&TmSec);
702  #endif
703  IAssert(TSecTm::GetTmSec(LocTm, AbsSec));
704  return TSecTm(AbsSec);
705 }
#define IAssert(Cond)
Definition: bd.h:262
static const uint Mx
Definition: dt.h:1152
unsigned int uint
Definition: bd.h:11
TSecTm()
Definition: tm.h:92
static bool GetTmSec(const int &YearN, const int &MonthN, const int &DayN, const int &HourN, const int &MinN, const int &SecN, uint &AbsSec)
Definition: tm.cpp:363
int TSecTm::GetDayN ( ) const

Definition at line 573 of file tm.cpp.

573  {
574  struct tm Tm;
575  IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
576  return Tm.tm_mday;
577 }
#define IAssert(Cond)
Definition: bd.h:262
bool IsDef() const
Definition: tm.h:123
TUInt AbsSecs
Definition: tm.h:83
static bool GetTmStruct(const uint &AbsSec, struct tm &Tm)
Definition: tm.cpp:416
int TSecTm::GetDayOfWeekN ( ) const

Definition at line 579 of file tm.cpp.

579  {
580  struct tm Tm;
581  IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
582  return Tm.tm_wday + 1;
583 }
#define IAssert(Cond)
Definition: bd.h:262
bool IsDef() const
Definition: tm.h:123
TUInt AbsSecs
Definition: tm.h:83
static bool GetTmStruct(const uint &AbsSec, struct tm &Tm)
Definition: tm.cpp:416
TStr TSecTm::GetDayOfWeekNm ( const TLoc Loc = lUs) const

Definition at line 585 of file tm.cpp.

585  {
586  struct tm Tm;
587  IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
588  return TTmInfo::GetDayOfWeekNm(Tm.tm_wday+1, Loc);
589 }
#define IAssert(Cond)
Definition: bd.h:262
bool IsDef() const
Definition: tm.h:123
static TStr GetDayOfWeekNm(const int &DayOfWeekN, const TLoc &Loc=lUs)
Definition: tm.cpp:71
TUInt AbsSecs
Definition: tm.h:83
static bool GetTmStruct(const uint &AbsSec, struct tm &Tm)
Definition: tm.cpp:416
TStr TSecTm::GetDayPart ( ) const

Definition at line 669 of file tm.cpp.

669  {
670  const int Hour = GetHourN();
671  if (0 <= Hour && Hour < 6) { return "Night"; }
672  else if (6 <= Hour && Hour < 12) { return "Morning"; }
673  else if (12 <= Hour && Hour < 18) { return "Afternoon"; }
674  else if (18 <= Hour && Hour < 24) { return "Evening"; }
675  return "";
676 }
int GetHourN() const
Definition: tm.cpp:591
uint TSecTm::GetDSecs ( const TSecTm SecTm1,
const TSecTm SecTm2 
)
static

Definition at line 678 of file tm.cpp.

678  {
679  IAssert(SecTm1.IsDef()&&SecTm2.IsDef());
680  const time_t Time1= time_t(SecTm1.AbsSecs());
681  const time_t Time2= time_t(SecTm2.AbsSecs());
682  return uint(difftime(Time2, Time1));
683 }
#define IAssert(Cond)
Definition: bd.h:262
bool IsDef() const
Definition: tm.h:123
unsigned int uint
Definition: bd.h:11
TUInt AbsSecs
Definition: tm.h:83
TStr TSecTm::GetDtMdyStr ( ) const

Definition at line 496 of file tm.cpp.

496  {
497  struct tm Tm;
498  IAssert(GetTmStruct(AbsSecs(), Tm));
499  return TStr::Fmt("%02d/%02d%/%04d", Tm.tm_mon+1, Tm.tm_mday, Tm.tm_year+1900);
500 }
#define IAssert(Cond)
Definition: bd.h:262
TUInt AbsSecs
Definition: tm.h:83
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
static bool GetTmStruct(const uint &AbsSec, struct tm &Tm)
Definition: tm.cpp:416
TStr TSecTm::GetDtStr ( const TLoc Loc = lUs) const

Definition at line 484 of file tm.cpp.

484  {
485  if (IsDef()){
486  struct tm Tm;
487  IAssert(GetTmStruct(AbsSecs(), Tm));
488  return TStr::Fmt("%s %s %d %d",
489  TTmInfo::GetDayOfWeekNm(Tm.tm_wday + 1, Loc).CStr(),
490  TTmInfo::GetMonthNm(Tm.tm_mon + 1, Loc).CStr(), Tm.tm_year+1900);
491  } else {
492  return "Undef";
493  }
494 }
#define IAssert(Cond)
Definition: bd.h:262
bool IsDef() const
Definition: tm.h:123
static TStr GetDayOfWeekNm(const int &DayOfWeekN, const TLoc &Loc=lUs)
Definition: tm.cpp:71
static TStr GetMonthNm(const int &MonthN, const TLoc &Loc=lUs)
Definition: tm.cpp:50
TUInt AbsSecs
Definition: tm.h:83
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
char * CStr()
Definition: dt.h:476
static bool GetTmStruct(const uint &AbsSec, struct tm &Tm)
Definition: tm.cpp:416
TSecTm TSecTm::GetDtTm ( const int &  YearN,
const int &  MonthN,
const int &  DayN 
)
static

Definition at line 933 of file tm.cpp.

933  {
934  uint AbsSecs;
935  TSecTm::GetTmSec(YearN, MonthN, DayN, 0, 0, 0, AbsSecs);
936  return TSecTm(AbsSecs);
937 }
unsigned int uint
Definition: bd.h:11
TSecTm()
Definition: tm.h:92
static bool GetTmSec(const int &YearN, const int &MonthN, const int &DayN, const int &HourN, const int &MinN, const int &SecN, uint &AbsSec)
Definition: tm.cpp:363
TUInt AbsSecs
Definition: tm.h:83
TSecTm TSecTm::GetDtTm ( const TSecTm Tm)
static

Definition at line 939 of file tm.cpp.

939  {
940  int DaySecs=Tm.GetHourN()*3600+Tm.GetMinN()*60+Tm.GetSecN();
941  TSecTm DtTm(Tm.AbsSecs-DaySecs);
942  return DtTm;
943 }
int GetMinN() const
Definition: tm.cpp:597
int GetSecN() const
Definition: tm.cpp:603
int GetHourN() const
Definition: tm.cpp:591
TUInt AbsSecs
Definition: tm.h:83
Definition: tm.h:81
TSecTm TSecTm::GetDtTmFromDmyStr ( const TStr DmyStr)
static

Definition at line 761 of file tm.cpp.

761  {
762  int DmyStrLen=DmyStr.Len();
763  // day
764  TChA ChA; int ChN=0;
765  while ((ChN<DmyStrLen)&&(DmyStr[ChN]!='/')&&(DmyStr[ChN]!='-')){
766  ChA+=DmyStr[ChN]; ChN++;}
767  TStr DayStr=ChA;
768  // month
769  ChA.Clr(); ChN++;
770  while ((ChN<DmyStrLen)&&(DmyStr[ChN]!='/')&&(DmyStr[ChN]!='-')){
771  ChA+=DmyStr[ChN]; ChN++;}
772  TStr MonthStr=ChA;
773  // year
774  ChA.Clr(); ChN++;
775  while (ChN<DmyStrLen){
776  ChA+=DmyStr[ChN]; ChN++;}
777  TStr YearStr=ChA;
778  // transform to numbers
779  int DayN=DayStr.GetInt(-1);
780  int MonthN=MonthStr.GetInt(-1);
781  int YearN=YearStr.GetInt(-1);
782  if (MonthN == -1){
783  MonthN = TTmInfo::GetMonthN(MonthStr.ToCap()); }
784  if ((DayN==-1)||(MonthN==-1)||(YearN==-1)){
785  return TSecTm();
786  } else {
787  if (YearN<1000){
788  if (YearN<70){YearN+=2000;} else {YearN+=1900;}}
789  // construct the date
790  return GetDtTm(YearN, MonthN, DayN);
791  }
792  return TSecTm();
793 }
int GetInt() const
Definition: dt.h:579
int Len() const
Definition: dt.h:487
void Clr()
Definition: dt.h:258
TStr & ToCap()
Definition: dt.cpp:764
TSecTm()
Definition: tm.h:92
Definition: dt.h:201
static TSecTm GetDtTm(const int &YearN, const int &MonthN, const int &DayN)
Definition: tm.cpp:933
Definition: dt.h:412
static int GetMonthN(const TStr &MonthNm, const TLoc &Loc=lUs)
Definition: tm.cpp:39
TSecTm TSecTm::GetDtTmFromHmsStr ( const TStr HmsStr)
static

Definition at line 707 of file tm.cpp.

707  {
708  int HmsStrLen=HmsStr.Len();
709  // hour
710  TChA ChA; int ChN=0;
711  while ((ChN<HmsStrLen)&&(HmsStr[ChN]!=':')){ChA+=HmsStr[ChN]; ChN++;}
712  TStr HourStr=ChA;
713  // minute
714  ChA.Clr(); ChN++;
715  while ((ChN<HmsStrLen)&&(HmsStr[ChN]!=':')){ChA+=HmsStr[ChN]; ChN++;}
716  TStr MinStr=ChA;
717  // second
718  ChA.Clr(); ChN++;
719  while (ChN<HmsStrLen){ChA+=HmsStr[ChN]; ChN++;}
720  TStr SecStr=ChA;
721  // transform to numbers
722  int HourN=HourStr.GetInt();
723  int MinN=MinStr.GetInt();
724  int SecN=SecStr.GetInt();
725  // construct the time
727  Tm.AddHours(HourN);
728  Tm.AddMins(MinN);
729  Tm.AddSecs(SecN);
730  return Tm;
731 }
int GetInt() const
Definition: dt.h:579
int Len() const
Definition: dt.h:487
void Clr()
Definition: dt.h:258
TSecTm & AddMins(const int &Mins)
Definition: tm.h:159
TSecTm & AddSecs(const int &Secs)
Definition: tm.h:155
Definition: dt.h:201
Definition: tm.h:81
Definition: dt.h:412
TSecTm & AddHours(const int &Hours)
Definition: tm.h:163
static TSecTm GetZeroTm()
Definition: tm.h:186
TSecTm TSecTm::GetDtTmFromMdyHmsPmStr ( const TStr MdyHmsPmStr,
const char &  DateSepCh = '/',
const char &  TimeSepCh = ':' 
)
static

Definition at line 795 of file tm.cpp.

796  {
797  int MdyHmsPmStrLen=MdyHmsPmStr.Len();
798  // month
799  TChA ChA; int ChN=0;
800  while ((ChN<MdyHmsPmStrLen)&&(MdyHmsPmStr[ChN]!=DateSepCh)){
801  ChA+=MdyHmsPmStr[ChN]; ChN++;}
802  TStr MonthStr=ChA;
803  // day
804  ChA.Clr(); ChN++;
805  while ((ChN<MdyHmsPmStrLen)&&(MdyHmsPmStr[ChN]!=DateSepCh)){
806  ChA+=MdyHmsPmStr[ChN]; ChN++;}
807  TStr DayStr=ChA;
808  // year
809  ChA.Clr(); ChN++;
810  while ((ChN<MdyHmsPmStrLen)&&(MdyHmsPmStr[ChN]!=' ')){
811  ChA+=MdyHmsPmStr[ChN]; ChN++;}
812  TStr YearStr=ChA;
813  // hour
814  ChA.Clr(); ChN++;
815  while ((ChN<MdyHmsPmStrLen)&&(MdyHmsPmStr[ChN]!=TimeSepCh)){
816  ChA+=MdyHmsPmStr[ChN]; ChN++;}
817  TStr HourStr=ChA;
818  // minute
819  ChA.Clr(); ChN++;
820  while ((ChN<MdyHmsPmStrLen)&&(MdyHmsPmStr[ChN]!=TimeSepCh)){
821  ChA+=MdyHmsPmStr[ChN]; ChN++;}
822  TStr MinStr=ChA;
823  // second
824  ChA.Clr(); ChN++;
825  while ((ChN<MdyHmsPmStrLen)&&(MdyHmsPmStr[ChN]!=' ')){
826  ChA+=MdyHmsPmStr[ChN]; ChN++;}
827  TStr SecStr=ChA;
828  // AM/PM
829  ChA.Clr(); ChN++;
830  while (ChN<MdyHmsPmStrLen){
831  ChA+=MdyHmsPmStr[ChN]; ChN++;}
832  TStr AmPmStr=ChA;
833  // transform to numbers
834  int MonthN=MonthStr.GetInt();
835  int DayN=DayStr.GetInt();
836  int YearN=YearStr.GetInt();
837  int HourN; int MinN; int SecN;
838  if (HourStr.IsInt()){
839  HourN=HourStr.GetInt();
840  MinN=MinStr.GetInt();
841  SecN=SecStr.GetInt();
842  if (AmPmStr=="AM"){} else if (AmPmStr=="PM"){HourN+=12;} else {Fail;}
843  } else {
844  HourN=0; MinN=0; SecN=0;
845  }
846  // construct the time
847  TSecTm Tm=TSecTm::GetDtTm(YearN, MonthN, DayN);
848  Tm.AddHours(HourN);
849  Tm.AddMins(MinN);
850  Tm.AddSecs(SecN);
851  return Tm;
852 }
int GetInt() const
Definition: dt.h:579
int Len() const
Definition: dt.h:487
bool IsInt(const bool &Check, const int &MnVal, const int &MxVal, int &Val) const
Definition: dt.cpp:1159
#define Fail
Definition: bd.h:238
void Clr()
Definition: dt.h:258
TSecTm & AddMins(const int &Mins)
Definition: tm.h:159
TSecTm & AddSecs(const int &Secs)
Definition: tm.h:155
Definition: dt.h:201
Definition: tm.h:81
static TSecTm GetDtTm(const int &YearN, const int &MonthN, const int &DayN)
Definition: tm.cpp:933
Definition: dt.h:412
TSecTm & AddHours(const int &Hours)
Definition: tm.h:163
TSecTm TSecTm::GetDtTmFromMdyStr ( const TStr MdyStr)
static

Definition at line 733 of file tm.cpp.

733  {
734  int MdyStrLen=MdyStr.Len();
735  // month
736  TChA ChA; int ChN=0;
737  while ((ChN<MdyStrLen)&&(MdyStr[ChN]!='/')){
738  ChA+=MdyStr[ChN]; ChN++;}
739  TStr MonthStr=ChA;
740  // day
741  ChA.Clr(); ChN++;
742  while ((ChN<MdyStrLen)&&(MdyStr[ChN]!='/')){
743  ChA+=MdyStr[ChN]; ChN++;}
744  TStr DayStr=ChA;
745  // year
746  ChA.Clr(); ChN++;
747  while (ChN<MdyStrLen){
748  ChA+=MdyStr[ChN]; ChN++;}
749  TStr YearStr=ChA;
750  // transform to numbers
751  int MonthN=MonthStr.GetInt();
752  int DayN=DayStr.GetInt();
753  int YearN=YearStr.GetInt();
754  if (YearN<1000){
755  if (YearN<70){YearN+=2000;} else {YearN+=1900;}}
756  // construct the date
757  return GetDtTm(YearN, MonthN, DayN);
758 }
int GetInt() const
Definition: dt.h:579
int Len() const
Definition: dt.h:487
void Clr()
Definition: dt.h:258
Definition: dt.h:201
static TSecTm GetDtTm(const int &YearN, const int &MonthN, const int &DayN)
Definition: tm.cpp:933
Definition: dt.h:412
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.

911  {
912  TChA Tmp = YmdHmsPmStr;
913  TVec<char *> FldV;
914  // get the sequences of numbers
915  for (char *c = (char *) Tmp.CStr(); *c; c++) {
916  if (TCh::IsNum(*c)) {
917  FldV.Add(c);
918  while (TCh::IsNum(*c)) { c++; }
919  c--;
920  } else { *c = 0; }
921  }
922  const int Y = atoi(FldV[YearId]);
923  const int M = atoi(FldV[MonId]);
924  const int D = atoi(FldV[DayId]);
925  const int H = atoi(FldV[HourId]);
926  const int m = atoi(FldV[MinId]);
927  const int S = atoi(FldV[SecId]);
928  IAssert(Y>0 && M>0 && D>0 && M<13 && D<32);
929  IAssert(H>=0 && H<24 && m>=0 && m<60 && S>=0 && S<60);
930  return TSecTm(Y,M,D,H,m,S);
931 }
#define IAssert(Cond)
Definition: bd.h:262
static bool IsNum(const char &Ch)
Definition: dt.h:972
TSecTm()
Definition: tm.h:92
char * CStr()
Definition: dt.h:255
Definition: dt.h:201
TSizeTy Add()
Adds a new element at the end of the vector, after its current last element.
Definition: ds.h:559
TSecTm TSecTm::GetDtTmFromYmdHmsStr ( const TStr YmdHmsPmStr,
const char &  DateSepCh = '-',
const char &  TimeSepCh = ':' 
)
static

Definition at line 854 of file tm.cpp.

855  {
856  int YmdHmsPmStrLen=YmdHmsPmStr.Len();
857  // year
858  TChA ChA; int ChN=0;
859  while ((ChN<YmdHmsPmStrLen)&&(YmdHmsPmStr[ChN]!=DateSepCh)){
860  ChA+=YmdHmsPmStr[ChN]; ChN++;}
861  TStr YearStr=ChA;
862  // month
863  ChA.Clr(); ChN++;
864  while ((ChN<YmdHmsPmStrLen)&&(YmdHmsPmStr[ChN]!=DateSepCh)){
865  ChA+=YmdHmsPmStr[ChN]; ChN++;}
866  TStr MonthStr=ChA;
867  // day
868  ChA.Clr(); ChN++;
869  while ((ChN<YmdHmsPmStrLen)&&(YmdHmsPmStr[ChN]!=' ')){
870  ChA+=YmdHmsPmStr[ChN]; ChN++;}
871  TStr DayStr=ChA;
872  // hour
873  ChA.Clr(); ChN++;
874  while ((ChN<YmdHmsPmStrLen)&&(YmdHmsPmStr[ChN]!=TimeSepCh)){
875  ChA+=YmdHmsPmStr[ChN]; ChN++;}
876  TStr HourStr=ChA;
877  // minute
878  ChA.Clr(); ChN++;
879  while ((ChN<YmdHmsPmStrLen)&&(YmdHmsPmStr[ChN]!=TimeSepCh)){
880  ChA+=YmdHmsPmStr[ChN]; ChN++;}
881  TStr MinStr=ChA;
882  // second
883  ChA.Clr(); ChN++;
884  while (ChN<YmdHmsPmStrLen){
885  ChA+=YmdHmsPmStr[ChN]; ChN++;}
886  TStr SecStr=ChA;
887  // transform to numbers
888  int MonthN=MonthStr.GetInt();
889  int DayN=DayStr.GetInt();
890  int YearN=YearStr.GetInt();
891  int HourN; int MinN; int SecN;
892  if (HourStr.IsInt()){
893  HourN=HourStr.GetInt();
894  MinN=MinStr.GetInt();
895  SecN=SecStr.GetInt();
896  } else {
897  HourN=0; MinN=0; SecN=0;
898  }
899  // construct the time
900  TSecTm Tm=TSecTm::GetDtTm(YearN, MonthN, DayN);
901  Tm.AddHours(HourN);
902  Tm.AddMins(MinN);
903  Tm.AddSecs(SecN);
904  return Tm;
905 }
int GetInt() const
Definition: dt.h:579
int Len() const
Definition: dt.h:487
bool IsInt(const bool &Check, const int &MnVal, const int &MxVal, int &Val) const
Definition: dt.cpp:1159
void Clr()
Definition: dt.h:258
TSecTm & AddMins(const int &Mins)
Definition: tm.h:159
TSecTm & AddSecs(const int &Secs)
Definition: tm.h:155
Definition: dt.h:201
Definition: tm.h:81
static TSecTm GetDtTm(const int &YearN, const int &MonthN, const int &DayN)
Definition: tm.cpp:933
Definition: dt.h:412
TSecTm & AddHours(const int &Hours)
Definition: tm.h:163
TStr TSecTm::GetDtTmSortFNmStr ( ) const

Definition at line 545 of file tm.cpp.

545  {
546  return
547  TInt::GetStr(GetYearN(), "%04d")+"-"+
548  TInt::GetStr(GetMonthN(), "%02d")+"-"+
549  TInt::GetStr(GetDayN(), "%02d")+"_"+
550  TInt::GetStr(GetHourN(), "%02d")+"-"+
551  TInt::GetStr(GetMinN(), "%02d")+"-"+
552  TInt::GetStr(GetSecN(), "%02d");
553 }
int GetMinN() const
Definition: tm.cpp:597
TStr GetStr() const
Definition: dt.h:1105
int GetYearN() const
Definition: tm.cpp:555
int GetMonthN() const
Definition: tm.cpp:561
int GetSecN() const
Definition: tm.cpp:603
int GetHourN() const
Definition: tm.cpp:591
int GetDayN() const
Definition: tm.cpp:573
TStr TSecTm::GetDtTmSortStr ( ) const

Definition at line 535 of file tm.cpp.

535  {
536  return
537  TInt::GetStr(GetYearN(), "%04d")+"/"+
538  TInt::GetStr(GetMonthN(), "%02d")+"/"+
539  TInt::GetStr(GetDayN(), "%02d")+" "+
540  TInt::GetStr(GetHourN(), "%02d")+":"+
541  TInt::GetStr(GetMinN(), "%02d")+":"+
542  TInt::GetStr(GetSecN(), "%02d");
543 }
int GetMinN() const
Definition: tm.cpp:597
TStr GetStr() const
Definition: dt.h:1105
int GetYearN() const
Definition: tm.cpp:555
int GetMonthN() const
Definition: tm.cpp:561
int GetSecN() const
Definition: tm.cpp:603
int GetHourN() const
Definition: tm.cpp:591
int GetDayN() const
Definition: tm.cpp:573
TStr TSecTm::GetDtYmdStr ( ) const

Definition at line 502 of file tm.cpp.

502  {
503  struct tm Tm;
504  IAssert(GetTmStruct(AbsSecs(), Tm));
505  return TStr::Fmt("%04d-%02d-%02d", Tm.tm_year+1900, Tm.tm_mon+1, Tm.tm_mday);
506 }
#define IAssert(Cond)
Definition: bd.h:262
TUInt AbsSecs
Definition: tm.h:83
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
static bool GetTmStruct(const uint &AbsSec, struct tm &Tm)
Definition: tm.cpp:416
int TSecTm::GetHourN ( ) const

Definition at line 591 of file tm.cpp.

591  {
592  struct tm Tm;
593  IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
594  return Tm.tm_hour;
595 }
#define IAssert(Cond)
Definition: bd.h:262
bool IsDef() const
Definition: tm.h:123
TUInt AbsSecs
Definition: tm.h:83
static bool GetTmStruct(const uint &AbsSec, struct tm &Tm)
Definition: tm.cpp:416
uint TSecTm::GetInUnits ( const TTmUnit TmUnit) const

Definition at line 645 of file tm.cpp.

645  {
646  static const int DayZero = TJulianDate::GetJulianDateN(1, 1, 1970);
647  if (TmUnit == tmu1Sec) { return AbsSecs; }
648  struct tm Time;
649  IAssert(IsDef() && GetTmStruct(AbsSecs(), Time));
650  switch (TmUnit) {
651  case tmu1Min : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, Time.tm_min, 0).GetAbsSecs()/60;
652  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);
653  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);
654  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);
655  case tmu1Hour : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, 0, 0).GetAbsSecs()/3600;
656  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);
657  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);
658  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);
659  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);
660  case tmuDay : return TJulianDate::GetJulianDateN(Time.tm_mday, Time.tm_mon+1, 1900+Time.tm_year) - DayZero;
661  case tmuWeek : return (TJulianDate::GetJulianDateN(Time.tm_mday, Time.tm_mon+1, 1900+Time.tm_year)-DayZero)/7;
662  case tmuMonth : return 12*(Time.tm_year-70)+Time.tm_mon+1;
663  case tmuYear : return Time.tm_year+1900;
664  default : Fail;
665  }
666  return TUInt::Mx;
667 }
#define IAssert(Cond)
Definition: bd.h:262
static int GetJulianDateN(int d, int m, int y)
Definition: tm.cpp:303
Definition: tm.h:13
Definition: tm.h:13
bool IsDef() const
Definition: tm.h:123
Definition: tm.h:12
static const uint Mx
Definition: dt.h:1152
#define Fail
Definition: bd.h:238
Definition: tm.h:13
Definition: tm.h:13
Definition: tm.h:12
Definition: tm.h:12
Definition: tm.h:13
Definition: tm.h:14
TSecTm()
Definition: tm.h:92
TUInt AbsSecs
Definition: tm.h:83
Definition: tm.h:12
Definition: tm.h:12
Definition: tm.h:13
Definition: tm.h:14
Definition: tm.h:13
static bool GetTmStruct(const uint &AbsSec, struct tm &Tm)
Definition: tm.cpp:416
int TSecTm::GetMemUsed ( ) const
inline

Definition at line 117 of file tm.h.

117 {return AbsSecs.GetMemUsed();}
int GetMemUsed() const
Definition: dt.h:1180
TUInt AbsSecs
Definition: tm.h:83
int TSecTm::GetMinN ( ) const

Definition at line 597 of file tm.cpp.

597  {
598  struct tm Tm;
599  IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
600  return Tm.tm_min;
601 }
#define IAssert(Cond)
Definition: bd.h:262
bool IsDef() const
Definition: tm.h:123
TUInt AbsSecs
Definition: tm.h:83
static bool GetTmStruct(const uint &AbsSec, struct tm &Tm)
Definition: tm.cpp:416
int TSecTm::GetMonthN ( ) const

Definition at line 561 of file tm.cpp.

561  {
562  struct tm Tm;
563  IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
564  return Tm.tm_mon+1;
565 }
#define IAssert(Cond)
Definition: bd.h:262
bool IsDef() const
Definition: tm.h:123
TUInt AbsSecs
Definition: tm.h:83
static bool GetTmStruct(const uint &AbsSec, struct tm &Tm)
Definition: tm.cpp:416
TStr TSecTm::GetMonthNm ( const TLoc Loc = lUs) const

Definition at line 567 of file tm.cpp.

567  {
568  struct tm Tm;
569  IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
570  return TTmInfo::GetMonthNm(Tm.tm_mon+1, Loc);
571 }
#define IAssert(Cond)
Definition: bd.h:262
bool IsDef() const
Definition: tm.h:123
static TStr GetMonthNm(const int &MonthN, const TLoc &Loc=lUs)
Definition: tm.cpp:50
TUInt AbsSecs
Definition: tm.h:83
static bool GetTmStruct(const uint &AbsSec, struct tm &Tm)
Definition: tm.cpp:416
int TSecTm::GetPrimHashCd ( ) const
inline

Definition at line 119 of file tm.h.

119 {return AbsSecs.GetPrimHashCd();}
TUInt AbsSecs
Definition: tm.h:83
int GetPrimHashCd() const
Definition: dt.h:1182
int TSecTm::GetSecHashCd ( ) const
inline

Definition at line 120 of file tm.h.

120 {return AbsSecs.GetSecHashCd();}
TUInt AbsSecs
Definition: tm.h:83
int GetSecHashCd() const
Definition: dt.h:1183
int TSecTm::GetSecN ( ) const

Definition at line 603 of file tm.cpp.

603  {
604  struct tm Tm;
605  IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
606  return Tm.tm_sec;
607 }
#define IAssert(Cond)
Definition: bd.h:262
bool IsDef() const
Definition: tm.h:123
TUInt AbsSecs
Definition: tm.h:83
static bool GetTmStruct(const uint &AbsSec, struct tm &Tm)
Definition: tm.cpp:416
TStr TSecTm::GetStr ( const TLoc Loc = lUs) const

Definition at line 457 of file tm.cpp.

457  {
458  if (IsDef()) {
459  struct tm Tm;
460  IAssert(GetTmStruct(AbsSecs(), Tm));
461  // Wed May 14 15:30:17 2003
462  return TStr::Fmt("%s %s %d %02d:%02d:%02d %d",
463  TTmInfo::GetDayOfWeekNm(Tm.tm_wday + 1, Loc).CStr(),
464  TTmInfo::GetMonthNm(Tm.tm_mon + 1, Loc).CStr(),
465  Tm.tm_mday, Tm.tm_hour, Tm.tm_min, Tm.tm_sec, Tm.tm_year+1900);
466  } else {
467  return "Undef";
468  }
469 }
#define IAssert(Cond)
Definition: bd.h:262
bool IsDef() const
Definition: tm.h:123
static TStr GetDayOfWeekNm(const int &DayOfWeekN, const TLoc &Loc=lUs)
Definition: tm.cpp:71
static TStr GetMonthNm(const int &MonthN, const TLoc &Loc=lUs)
Definition: tm.cpp:50
TUInt AbsSecs
Definition: tm.h:83
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
char * CStr()
Definition: dt.h:476
static bool GetTmStruct(const uint &AbsSec, struct tm &Tm)
Definition: tm.cpp:416
TStr TSecTm::GetStr ( const TTmUnit TmUnit) const

Definition at line 471 of file tm.cpp.

471  {
472  if (TmUnit == tmuYear) {
473  return TInt::GetStr(GetYearN()); }
474  else if (TmUnit == tmuMonth) {
475  return TStr::Fmt("%04d-%02d", GetYearN(), GetMonthN()); }
476  else if (TmUnit == tmuDay) {
477  return TStr::Fmt("%04d-%02d-%02d", GetYearN(), GetMonthN(), GetDayN()); }
478  else {
479  return TStr::Fmt("%04d-%02d-%02d %02d:%02d:%02d",
480  GetYearN(), GetMonthN(), GetDayN(), GetHourN(), GetMinN(), GetSecN());
481  }
482 }
int GetMinN() const
Definition: tm.cpp:597
TStr GetStr() const
Definition: dt.h:1105
int GetYearN() const
Definition: tm.cpp:555
int GetMonthN() const
Definition: tm.cpp:561
Definition: tm.h:13
Definition: tm.h:14
int GetSecN() const
Definition: tm.cpp:603
int GetHourN() const
Definition: tm.cpp:591
int GetDayN() const
Definition: tm.cpp:573
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
Definition: tm.h:14
TStr TSecTm::GetTmMinStr ( ) const

Definition at line 525 of file tm.cpp.

525  {
526  if (IsDef()){
527  struct tm Tm;
528  IAssert(GetTmStruct(AbsSecs(), Tm));
529  return TStr::Fmt("%02d:%02d", Tm.tm_min, Tm.tm_sec);
530  } else {
531  return "Undef";
532  }
533 }
#define IAssert(Cond)
Definition: bd.h:262
bool IsDef() const
Definition: tm.h:123
TUInt AbsSecs
Definition: tm.h:83
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
static bool GetTmStruct(const uint &AbsSec, struct tm &Tm)
Definition: tm.cpp:416
bool TSecTm::GetTmSec ( const int &  YearN,
const int &  MonthN,
const int &  DayN,
const int &  HourN,
const int &  MinN,
const int &  SecN,
uint AbsSec 
)
staticprivate

Definition at line 363 of file tm.cpp.

363  {
364  AbsSec = 0;
365  // tm_isdst:
366  // - Positive if daylight saving time is in effect;
367  // - 0 if daylight saving time is not in effect;
368  // - negative if status of daylight saving time is unknown.
369  // The C run-time library assumes the United States's rules for implementing
370  // the calculation of Daylight Saving Time (DST).
371  struct tm Tm;
372  Tm.tm_year=YearN-1900; Tm.tm_mon=MonthN-1; Tm.tm_mday=DayN;
373  Tm.tm_hour=HourN; Tm.tm_min=MinN; Tm.tm_sec=SecN;
374  Tm.tm_wday=1; Tm.tm_yday=1;
375  Tm.tm_isdst=-1;
376  return TSecTm::GetTmSec(Tm, AbsSec);
377 }
static bool GetTmSec(const int &YearN, const int &MonthN, const int &DayN, const int &HourN, const int &MinN, const int &SecN, uint &AbsSec)
Definition: tm.cpp:363
bool TSecTm::GetTmSec ( struct tm &  Tm,
uint AbsSec 
)
staticprivate

Definition at line 407 of file tm.cpp.

407  {
408  const time_t GmtTime = MkGmTime(&Tm);
409  EAssertR(uint(GmtTime) < TUInt::Mx,
410  TStr::Fmt("Time out of range: %d/%d/%d %02d:%02d:%02d",
411  Tm.tm_year, Tm.tm_mon, Tm.tm_mday, Tm.tm_hour, Tm.tm_min, Tm.tm_sec).CStr());
412  AbsSec = uint(GmtTime);
413  return GmtTime >= 0;
414 }
static const uint Mx
Definition: dt.h:1152
unsigned int uint
Definition: bd.h:11
static time_t MkGmTime(struct tm *t)
Definition: tm.cpp:380
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
#define EAssertR(Cond, MsgStr)
Definition: bd.h:283
char * CStr()
Definition: dt.h:476
TStr TSecTm::GetTmStr ( ) const

Definition at line 515 of file tm.cpp.

515  {
516  if (IsDef()){
517  struct tm Tm;
518  IAssert(GetTmStruct(AbsSecs(), Tm));
519  return TStr::Fmt("%02d:%02d:%02d", Tm.tm_hour, Tm.tm_min, Tm.tm_sec);
520  } else {
521  return "Undef";
522  }
523 }
#define IAssert(Cond)
Definition: bd.h:262
bool IsDef() const
Definition: tm.h:123
TUInt AbsSecs
Definition: tm.h:83
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
static bool GetTmStruct(const uint &AbsSec, struct tm &Tm)
Definition: tm.cpp:416
bool TSecTm::GetTmStruct ( const uint AbsSec,
struct tm &  Tm 
)
staticprivate

Definition at line 416 of file tm.cpp.

416  {
417  const time_t TimeT = time_t(AbsSec);
418  #if defined(GLib_MSC)
419  return _gmtime64_s(&Tm, &TimeT) == 0;
420  #elif defined(GLib_BCB)
421  Tm=*gmtime(&TimeT); return true;
422  #else
423  return gmtime_r(&TimeT, &Tm) != NULL;
424  #endif
425 }
PXmlTok TSecTm::GetXmlTok ( ) const

Definition at line 446 of file tm.cpp.

446  {
447  PXmlTok NodeTok = TXmlTok::New("NodeTime");
448  NodeTok->AddArg("Year", GetYearN());
449  NodeTok->AddArg("Month", GetMonthN());
450  NodeTok->AddArg("Day", GetDayN());
451  NodeTok->AddArg("Hour", GetHourN());
452  NodeTok->AddArg("Min", GetMinN());
453  NodeTok->AddArg("Sec", GetSecN());
454  return NodeTok;
455 }
int GetMinN() const
Definition: tm.cpp:597
int GetYearN() const
Definition: tm.cpp:555
static PXmlTok New()
Definition: xml.h:212
int GetMonthN() const
Definition: tm.cpp:561
int GetSecN() const
Definition: tm.cpp:603
int GetHourN() const
Definition: tm.cpp:591
int GetDayN() const
Definition: tm.cpp:573
Definition: bd.h:196
int TSecTm::GetYearN ( ) const

Definition at line 555 of file tm.cpp.

555  {
556  struct tm Tm;
557  IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
558  return Tm.tm_year+1900;
559 }
#define IAssert(Cond)
Definition: bd.h:262
bool IsDef() const
Definition: tm.h:123
TUInt AbsSecs
Definition: tm.h:83
static bool GetTmStruct(const uint &AbsSec, struct tm &Tm)
Definition: tm.cpp:416
TStr TSecTm::GetYmdTmStr ( ) const

Definition at line 508 of file tm.cpp.

508  {
509  struct tm Tm;
510  IAssert(GetTmStruct(AbsSecs(), Tm));
511  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);
512 }
#define IAssert(Cond)
Definition: bd.h:262
TUInt AbsSecs
Definition: tm.h:83
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
static bool GetTmStruct(const uint &AbsSec, struct tm &Tm)
Definition: tm.cpp:416
static TSecTm TSecTm::GetZeroTm ( )
inlinestatic

Definition at line 186 of file tm.h.

186 {return TSecTm(0).AddHours(23);}
TSecTm()
Definition: tm.h:92
TSecTm TSecTm::GetZeroWeekTm ( )
static

Definition at line 685 of file tm.cpp.

685  {
686  TSecTm ZeroWeekTm=GetZeroTm();
687  while (ZeroWeekTm.GetDayOfWeekN()!=TTmInfo::MonN){
688  ZeroWeekTm.AddDays(1);}
689  return ZeroWeekTm;
690 }
TSecTm & AddDays(const int &Days)
Definition: tm.h:167
int GetDayOfWeekN() const
Definition: tm.cpp:579
Definition: tm.h:81
static const int MonN
Definition: tm.h:47
static TSecTm GetZeroTm()
Definition: tm.h:186
bool TSecTm::IsDef ( ) const
inline

Definition at line 123 of file tm.h.

123 {return uint(AbsSecs)!=TUInt::Mx;}
static const uint Mx
Definition: dt.h:1152
unsigned int uint
Definition: bd.h:11
TUInt AbsSecs
Definition: tm.h:83
void TSecTm::Load ( TSIn SIn)
inline

Definition at line 102 of file tm.h.

102 {AbsSecs.Load(SIn);}
void Load(TSIn &SIn)
Definition: dt.h:1159
TUInt AbsSecs
Definition: tm.h:83
TSecTm TSecTm::LoadTxt ( TILx Lx)
static

Definition at line 945 of file tm.cpp.

945  {
946  return TSecTm(Lx.GetInt());
947 }
int GetInt()
Definition: lx.h:181
TSecTm()
Definition: tm.h:92
time_t TSecTm::MkGmTime ( struct tm *  t)
staticprivate

Definition at line 380 of file tm.cpp.

380  {
381  static const int m_to_d[12] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
382  short month, year;
383  time_t result;
384  month = t->tm_mon;
385  year = t->tm_year + month / 12 + 1900;
386  month %= 12;
387  if (month < 0) {
388  year -= 1;
389  month += 12; }
390  result = (year - 1970) * 365 + (year - 1969) / 4 + m_to_d[month];
391  result = (year - 1970) * 365 + m_to_d[month];
392  if (month <= 1) { year -= 1; }
393  result += (year - 1968) / 4;
394  result -= (year - 1900) / 100;
395  result += (year - 1600) / 400;
396  result += t->tm_mday;
397  result -= 1;
398  result *= 24;
399  result += t->tm_hour;
400  result *= 60;
401  result += t->tm_min;
402  result *= 60;
403  result += t->tm_sec;
404  return result;
405 }
TSecTm::operator uint ( ) const
inline

Definition at line 94 of file tm.h.

94 {return AbsSecs.Val;}
TUInt AbsSecs
Definition: tm.h:83
uint Val
Definition: dt.h:1149
TSecTm& TSecTm::operator+= ( const uint Secs)
inline

Definition at line 109 of file tm.h.

109  {
110  IAssert(IsDef()); AbsSecs()+=Secs; return *this;}
#define IAssert(Cond)
Definition: bd.h:262
bool IsDef() const
Definition: tm.h:123
TUInt AbsSecs
Definition: tm.h:83
TSecTm& TSecTm::operator-= ( const uint Secs)
inline

Definition at line 111 of file tm.h.

111  {
112  IAssert(IsDef()); AbsSecs()-=Secs; return *this;}
#define IAssert(Cond)
Definition: bd.h:262
bool IsDef() const
Definition: tm.h:123
TUInt AbsSecs
Definition: tm.h:83
bool TSecTm::operator< ( const TSecTm SecTm) const
inline

Definition at line 115 of file tm.h.

115  {
116  IAssert(IsDef()&&SecTm.IsDef()); return AbsSecs<SecTm.AbsSecs;}
#define IAssert(Cond)
Definition: bd.h:262
bool IsDef() const
Definition: tm.h:123
TUInt AbsSecs
Definition: tm.h:83
TSecTm& TSecTm::operator= ( const TSecTm SecTm)
inline

Definition at line 105 of file tm.h.

105  {
106  AbsSecs=SecTm.AbsSecs; return *this;}
TUInt AbsSecs
Definition: tm.h:83
TSecTm& TSecTm::operator= ( const uint _AbsSecs)
inline

Definition at line 107 of file tm.h.

107  {
108  AbsSecs=_AbsSecs; return *this;}
TUInt AbsSecs
Definition: tm.h:83
bool TSecTm::operator== ( const TSecTm SecTm) const
inline

Definition at line 113 of file tm.h.

113  {
114  return AbsSecs==SecTm.AbsSecs;}
TUInt AbsSecs
Definition: tm.h:83
TSecTm TSecTm::Round ( const TTmUnit TmUnit) const

Definition at line 620 of file tm.cpp.

620  {
621  if (TmUnit == tmu1Sec) { return *this; }
622  struct tm Time;
623  IAssert(IsDef() && GetTmStruct(AbsSecs(), Time));
624  switch (TmUnit) {
625  case tmu1Min : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, Time.tm_min, 0);
626  case tmu10Min : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, 10*(Time.tm_min/10), 0);
627  case tmu15Min : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, 15*(Time.tm_min/15), 0);
628  case tmu30Min : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, 30*(Time.tm_min/30), 0);
629  case tmu1Hour : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, 0, 0);
630  case tmu2Hour : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, 2*(Time.tm_hour/2), 0, 0);
631  case tmu4Hour : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, 4*(Time.tm_hour/4), 0, 0);
632  case tmu6Hour : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, 6*(Time.tm_hour/6), 0, 0);
633  case tmu12Hour : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, 12*(Time.tm_hour/12), 0, 0);
634  case tmuDay : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, 0, 0, 0);
635  case tmuMonth : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, 1, 0, 0, 0);
636  case tmuYear : return TSecTm(Time.tm_year+1900, 1, 1, 0, 0, 0);
637  case tmuWeek : { int dd=1, mm=1, yy=1;
638  // week starts on Thursday, since 1.1.1970 is Thursday
639  const int Day = TJulianDate::GetJulianDateN(Time.tm_mday, Time.tm_mon+1, 1900+Time.tm_year);
640  TJulianDate::GetCalendarDate(3+7*(Day/7), dd, mm, yy); return TSecTm(yy, mm, dd, 0, 0, 0); }
641  default : Fail;
642  }
643  return TSecTm();
644 }
#define IAssert(Cond)
Definition: bd.h:262
static void GetCalendarDate(int jdn, int &dd, int &mm, int &yy)
Definition: tm.cpp:327
static int GetJulianDateN(int d, int m, int y)
Definition: tm.cpp:303
Definition: tm.h:13
Definition: tm.h:13
bool IsDef() const
Definition: tm.h:123
Definition: tm.h:12
#define Fail
Definition: bd.h:238
Definition: tm.h:13
Definition: tm.h:13
Definition: tm.h:12
Definition: tm.h:12
Definition: tm.h:13
Definition: tm.h:14
TSecTm()
Definition: tm.h:92
TUInt AbsSecs
Definition: tm.h:83
Definition: tm.h:12
Definition: tm.h:12
Definition: tm.h:13
Definition: tm.h:14
Definition: tm.h:13
static bool GetTmStruct(const uint &AbsSec, struct tm &Tm)
Definition: tm.cpp:416
void TSecTm::Save ( TSOut SOut) const
inline

Definition at line 103 of file tm.h.

103 {AbsSecs.Save(SOut);}
void Save(TSOut &SOut) const
Definition: dt.h:1160
TUInt AbsSecs
Definition: tm.h:83
void TSecTm::SaveTxt ( TOLx Lx) const

Definition at line 949 of file tm.cpp.

949  {
950  IAssert(int(AbsSecs) < TInt::Mx);
951  Lx.PutInt((int)AbsSecs);
952 }
#define IAssert(Cond)
Definition: bd.h:262
static const int Mx
Definition: dt.h:1047
void PutInt(const TInt &Int)
Definition: lx.h:277
TUInt AbsSecs
Definition: tm.h:83
TSecTm& TSecTm::SubDays ( const int &  Days)
inline

Definition at line 169 of file tm.h.

169  {
170  IAssert(IsDef() && uint(Days*24*3600) < AbsSecs); AbsSecs.Val-=uint(Days*24*3600); return *this;}
#define IAssert(Cond)
Definition: bd.h:262
bool IsDef() const
Definition: tm.h:123
unsigned int uint
Definition: bd.h:11
TUInt AbsSecs
Definition: tm.h:83
uint Val
Definition: dt.h:1149
TSecTm& TSecTm::SubHours ( const int &  Hours)
inline

Definition at line 165 of file tm.h.

165  {
166  IAssert(IsDef() && uint(Hours*3600) < AbsSecs); AbsSecs.Val-=uint(Hours*3600); return *this;}
#define IAssert(Cond)
Definition: bd.h:262
bool IsDef() const
Definition: tm.h:123
unsigned int uint
Definition: bd.h:11
TUInt AbsSecs
Definition: tm.h:83
uint Val
Definition: dt.h:1149
TSecTm& TSecTm::SubMins ( const int &  Mins)
inline

Definition at line 161 of file tm.h.

161  {
162  IAssert(IsDef() && uint(Mins*60) < AbsSecs); AbsSecs.Val-=uint(Mins*60); return *this;}
#define IAssert(Cond)
Definition: bd.h:262
bool IsDef() const
Definition: tm.h:123
unsigned int uint
Definition: bd.h:11
TUInt AbsSecs
Definition: tm.h:83
uint Val
Definition: dt.h:1149
TSecTm& TSecTm::SubSecs ( const int &  Secs)
inline

Definition at line 157 of file tm.h.

157  {
158  IAssert(IsDef() && uint(Secs) < AbsSecs); AbsSecs.Val-=uint(Secs); return *this;}
#define IAssert(Cond)
Definition: bd.h:262
bool IsDef() const
Definition: tm.h:123
unsigned int uint
Definition: bd.h:11
TUInt AbsSecs
Definition: tm.h:83
uint Val
Definition: dt.h:1149
TSecTm& TSecTm::SubWeeks ( const int &  Weeks)
inline

Definition at line 173 of file tm.h.

173  {
174  IAssert(IsDef() && uint(Weeks*7*24*3600) < AbsSecs); AbsSecs.Val-=uint(Weeks*7*24*3600); return *this;}
#define IAssert(Cond)
Definition: bd.h:262
bool IsDef() const
Definition: tm.h:123
unsigned int uint
Definition: bd.h:11
TUInt AbsSecs
Definition: tm.h:83
uint Val
Definition: dt.h:1149
void TSecTm::Undef ( )
inline

Definition at line 124 of file tm.h.

static const uint Mx
Definition: dt.h:1152
TUInt AbsSecs
Definition: tm.h:83

Member Data Documentation

TUInt TSecTm::AbsSecs
private

Definition at line 83 of file tm.h.


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