SNAP Library 3.0, User Reference  2016-07-20 17:56:49
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 GetYmdTmStr2 () 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:1154
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:1154
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:1151
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:282
int GetMonth() const
Definition: tm.h:276
int GetHour() const
Definition: tm.h:281
TSecTm()
Definition: tm.h:92
int GetYear() const
Definition: tm.h:275
int GetDay() const
Definition: tm.h:278
uint GetAbsSecs() const
Definition: tm.h:150
TUInt AbsSecs
Definition: tm.h:83
int GetSec() const
Definition: tm.h:283
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 168 of file tm.h.

168  {
169  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:1151
TSecTm& TSecTm::AddHours ( const int &  Hours)
inline

Definition at line 164 of file tm.h.

164  {
165  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:1151
TSecTm& TSecTm::AddMins ( const int &  Mins)
inline

Definition at line 160 of file tm.h.

160  {
161  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:1151
TSecTm& TSecTm::AddSecs ( const int &  Secs)
inline

Definition at line 156 of file tm.h.

156  {
157  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:1151
TSecTm& TSecTm::AddWeeks ( const int &  Weeks)
inline

Definition at line 172 of file tm.h.

172  {
173  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:1151
uint TSecTm::GetAbsSecs ( ) const
inline

Definition at line 150 of file tm.h.

150 {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 614 of file tm.cpp.

614  {
615  struct tm Tm;
616  EAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
617  Year = Tm.tm_year+1900;
618  Month = Tm.tm_mon+1;
619  Day = Tm.tm_mday;
620  Hour = Tm.tm_hour;
621  Min = Tm.tm_min;
622  Sec = Tm.tm_sec;
623 }
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 190 of file tm.h.

190 {return GetDtTm(GetCurTm());}
static TSecTm GetDtTm(const int &YearN, const int &MonthN, const int &DayN)
Definition: tm.cpp:938
static TSecTm GetCurTm()
Definition: tm.cpp:697
TSecTm TSecTm::GetCurTm ( )
static

Definition at line 697 of file tm.cpp.

697  {
698  const time_t TmSec = time(NULL);
699  struct tm LocTm;
700  uint AbsSec = TUInt::Mx;
701  #if defined(GLib_MSN)
702  localtime_s(&LocTm, &TmSec);
703  #elif defined(GLib_BCB)
704  LocTm = *localtime(&TmSec);
705  #else
706  LocTm = *localtime(&TmSec);
707  #endif
708  IAssert(TSecTm::GetTmSec(LocTm, AbsSec));
709  return TSecTm(AbsSec);
710 }
#define IAssert(Cond)
Definition: bd.h:262
static const uint Mx
Definition: dt.h:1154
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 578 of file tm.cpp.

578  {
579  struct tm Tm;
580  IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
581  return Tm.tm_mday;
582 }
#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 584 of file tm.cpp.

584  {
585  struct tm Tm;
586  IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
587  return Tm.tm_wday + 1;
588 }
#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 590 of file tm.cpp.

590  {
591  struct tm Tm;
592  IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
593  return TTmInfo::GetDayOfWeekNm(Tm.tm_wday+1, Loc);
594 }
#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 674 of file tm.cpp.

674  {
675  const int Hour = GetHourN();
676  if (0 <= Hour && Hour < 6) { return "Night"; }
677  else if (6 <= Hour && Hour < 12) { return "Morning"; }
678  else if (12 <= Hour && Hour < 18) { return "Afternoon"; }
679  else if (18 <= Hour && Hour < 24) { return "Evening"; }
680  return "";
681 }
int GetHourN() const
Definition: tm.cpp:596
uint TSecTm::GetDSecs ( const TSecTm SecTm1,
const TSecTm SecTm2 
)
static

Definition at line 683 of file tm.cpp.

683  {
684  IAssert(SecTm1.IsDef()&&SecTm2.IsDef());
685  const time_t Time1= time_t(SecTm1.AbsSecs());
686  const time_t Time2= time_t(SecTm2.AbsSecs());
687  return uint(difftime(Time2, Time1));
688 }
#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 938 of file tm.cpp.

938  {
939  uint AbsSecs;
940  TSecTm::GetTmSec(YearN, MonthN, DayN, 0, 0, 0, AbsSecs);
941  return TSecTm(AbsSecs);
942 }
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 944 of file tm.cpp.

944  {
945  int DaySecs=Tm.GetHourN()*3600+Tm.GetMinN()*60+Tm.GetSecN();
946  TSecTm DtTm(Tm.AbsSecs-DaySecs);
947  return DtTm;
948 }
int GetMinN() const
Definition: tm.cpp:602
int GetSecN() const
Definition: tm.cpp:608
int GetHourN() const
Definition: tm.cpp:596
TUInt AbsSecs
Definition: tm.h:83
Definition: tm.h:81
TSecTm TSecTm::GetDtTmFromDmyStr ( const TStr DmyStr)
static

Definition at line 766 of file tm.cpp.

766  {
767  int DmyStrLen=DmyStr.Len();
768  // day
769  TChA ChA; int ChN=0;
770  while ((ChN<DmyStrLen)&&(DmyStr[ChN]!='/')&&(DmyStr[ChN]!='-')){
771  ChA+=DmyStr[ChN]; ChN++;}
772  TStr DayStr=ChA;
773  // month
774  ChA.Clr(); ChN++;
775  while ((ChN<DmyStrLen)&&(DmyStr[ChN]!='/')&&(DmyStr[ChN]!='-')){
776  ChA+=DmyStr[ChN]; ChN++;}
777  TStr MonthStr=ChA;
778  // year
779  ChA.Clr(); ChN++;
780  while (ChN<DmyStrLen){
781  ChA+=DmyStr[ChN]; ChN++;}
782  TStr YearStr=ChA;
783  // transform to numbers
784  int DayN=DayStr.GetInt(-1);
785  int MonthN=MonthStr.GetInt(-1);
786  int YearN=YearStr.GetInt(-1);
787  if (MonthN == -1){
788  MonthN = TTmInfo::GetMonthN(MonthStr.ToCap()); }
789  if ((DayN==-1)||(MonthN==-1)||(YearN==-1)){
790  return TSecTm();
791  } else {
792  if (YearN<1000){
793  if (YearN<70){YearN+=2000;} else {YearN+=1900;}}
794  // construct the date
795  return GetDtTm(YearN, MonthN, DayN);
796  }
797  return TSecTm();
798 }
int GetInt() const
Definition: dt.h:578
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:938
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 712 of file tm.cpp.

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

Definition at line 800 of file tm.cpp.

801  {
802  int MdyHmsPmStrLen=MdyHmsPmStr.Len();
803  // month
804  TChA ChA; int ChN=0;
805  while ((ChN<MdyHmsPmStrLen)&&(MdyHmsPmStr[ChN]!=DateSepCh)){
806  ChA+=MdyHmsPmStr[ChN]; ChN++;}
807  TStr MonthStr=ChA;
808  // day
809  ChA.Clr(); ChN++;
810  while ((ChN<MdyHmsPmStrLen)&&(MdyHmsPmStr[ChN]!=DateSepCh)){
811  ChA+=MdyHmsPmStr[ChN]; ChN++;}
812  TStr DayStr=ChA;
813  // year
814  ChA.Clr(); ChN++;
815  while ((ChN<MdyHmsPmStrLen)&&(MdyHmsPmStr[ChN]!=' ')){
816  ChA+=MdyHmsPmStr[ChN]; ChN++;}
817  TStr YearStr=ChA;
818  // hour
819  ChA.Clr(); ChN++;
820  while ((ChN<MdyHmsPmStrLen)&&(MdyHmsPmStr[ChN]!=TimeSepCh)){
821  ChA+=MdyHmsPmStr[ChN]; ChN++;}
822  TStr HourStr=ChA;
823  // minute
824  ChA.Clr(); ChN++;
825  while ((ChN<MdyHmsPmStrLen)&&(MdyHmsPmStr[ChN]!=TimeSepCh)){
826  ChA+=MdyHmsPmStr[ChN]; ChN++;}
827  TStr MinStr=ChA;
828  // second
829  ChA.Clr(); ChN++;
830  while ((ChN<MdyHmsPmStrLen)&&(MdyHmsPmStr[ChN]!=' ')){
831  ChA+=MdyHmsPmStr[ChN]; ChN++;}
832  TStr SecStr=ChA;
833  // AM/PM
834  ChA.Clr(); ChN++;
835  while (ChN<MdyHmsPmStrLen){
836  ChA+=MdyHmsPmStr[ChN]; ChN++;}
837  TStr AmPmStr=ChA;
838  // transform to numbers
839  int MonthN=MonthStr.GetInt();
840  int DayN=DayStr.GetInt();
841  int YearN=YearStr.GetInt();
842  int HourN; int MinN; int SecN;
843  if (HourStr.IsInt()){
844  HourN=HourStr.GetInt();
845  MinN=MinStr.GetInt();
846  SecN=SecStr.GetInt();
847  if (AmPmStr=="AM"){} else if (AmPmStr=="PM"){HourN+=12;} else {Fail;}
848  } else {
849  HourN=0; MinN=0; SecN=0;
850  }
851  // construct the time
852  TSecTm Tm=TSecTm::GetDtTm(YearN, MonthN, DayN);
853  Tm.AddHours(HourN);
854  Tm.AddMins(MinN);
855  Tm.AddSecs(SecN);
856  return Tm;
857 }
int GetInt() const
Definition: dt.h:578
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:160
TSecTm & AddSecs(const int &Secs)
Definition: tm.h:156
Definition: dt.h:201
Definition: tm.h:81
static TSecTm GetDtTm(const int &YearN, const int &MonthN, const int &DayN)
Definition: tm.cpp:938
Definition: dt.h:412
TSecTm & AddHours(const int &Hours)
Definition: tm.h:164
TSecTm TSecTm::GetDtTmFromMdyStr ( const TStr MdyStr)
static

Definition at line 738 of file tm.cpp.

738  {
739  int MdyStrLen=MdyStr.Len();
740  // month
741  TChA ChA; int ChN=0;
742  while ((ChN<MdyStrLen)&&(MdyStr[ChN]!='/')){
743  ChA+=MdyStr[ChN]; ChN++;}
744  TStr MonthStr=ChA;
745  // day
746  ChA.Clr(); ChN++;
747  while ((ChN<MdyStrLen)&&(MdyStr[ChN]!='/')){
748  ChA+=MdyStr[ChN]; ChN++;}
749  TStr DayStr=ChA;
750  // year
751  ChA.Clr(); ChN++;
752  while (ChN<MdyStrLen){
753  ChA+=MdyStr[ChN]; ChN++;}
754  TStr YearStr=ChA;
755  // transform to numbers
756  int MonthN=MonthStr.GetInt();
757  int DayN=DayStr.GetInt();
758  int YearN=YearStr.GetInt();
759  if (YearN<1000){
760  if (YearN<70){YearN+=2000;} else {YearN+=1900;}}
761  // construct the date
762  return GetDtTm(YearN, MonthN, DayN);
763 }
int GetInt() const
Definition: dt.h:578
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:938
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 915 of file tm.cpp.

916  {
917  TChA Tmp = YmdHmsPmStr;
918  TVec<char *> FldV;
919  // get the sequences of numbers
920  for (char *c = (char *) Tmp.CStr(); *c; c++) {
921  if (TCh::IsNum(*c)) {
922  FldV.Add(c);
923  while (TCh::IsNum(*c)) { c++; }
924  c--;
925  } else { *c = 0; }
926  }
927  const int Y = atoi(FldV[YearId]);
928  const int M = atoi(FldV[MonId]);
929  const int D = atoi(FldV[DayId]);
930  const int H = atoi(FldV[HourId]);
931  const int m = atoi(FldV[MinId]);
932  const int S = atoi(FldV[SecId]);
933  IAssert(Y>0 && M>0 && D>0 && M<13 && D<32);
934  IAssert(H>=0 && H<24 && m>=0 && m<60 && S>=0 && S<60);
935  return TSecTm(Y,M,D,H,m,S);
936 }
#define IAssert(Cond)
Definition: bd.h:262
static bool IsNum(const char &Ch)
Definition: dt.h:974
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:574
TSecTm TSecTm::GetDtTmFromYmdHmsStr ( const TStr YmdHmsPmStr,
const char &  DateSepCh = '-',
const char &  TimeSepCh = ':' 
)
static

Definition at line 859 of file tm.cpp.

860  {
861  int YmdHmsPmStrLen=YmdHmsPmStr.Len();
862  // year
863  TChA ChA; int ChN=0;
864  while ((ChN<YmdHmsPmStrLen)&&(YmdHmsPmStr[ChN]!=DateSepCh)){
865  ChA+=YmdHmsPmStr[ChN]; ChN++;}
866  TStr YearStr=ChA;
867  // month
868  ChA.Clr(); ChN++;
869  while ((ChN<YmdHmsPmStrLen)&&(YmdHmsPmStr[ChN]!=DateSepCh)){
870  ChA+=YmdHmsPmStr[ChN]; ChN++;}
871  TStr MonthStr=ChA;
872  // day
873  ChA.Clr(); ChN++;
874  while ((ChN<YmdHmsPmStrLen)&&(YmdHmsPmStr[ChN]!=' ')){
875  ChA+=YmdHmsPmStr[ChN]; ChN++;}
876  TStr DayStr=ChA;
877  // hour
878  ChA.Clr(); ChN++;
879  while ((ChN<YmdHmsPmStrLen)&&(YmdHmsPmStr[ChN]!=TimeSepCh)){
880  ChA+=YmdHmsPmStr[ChN]; ChN++;}
881  TStr HourStr=ChA;
882  // minute
883  ChA.Clr(); ChN++;
884  while ((ChN<YmdHmsPmStrLen)&&(YmdHmsPmStr[ChN]!=TimeSepCh)){
885  ChA+=YmdHmsPmStr[ChN]; ChN++;}
886  TStr MinStr=ChA;
887  // second
888  ChA.Clr(); ChN++;
889  while (ChN<YmdHmsPmStrLen){
890  ChA+=YmdHmsPmStr[ChN]; ChN++;}
891  TStr SecStr=ChA;
892  // transform to numbers
893  int MonthN=MonthStr.GetInt();
894  int DayN=DayStr.GetInt();
895  int YearN=YearStr.GetInt();
896  int HourN; int MinN; int SecN;
897  if (HourStr.IsInt()){
898  HourN=HourStr.GetInt();
899  MinN=MinStr.GetInt();
900  SecN=SecStr.GetInt();
901  } else {
902  HourN=0; MinN=0; SecN=0;
903  }
904  // construct the time
905  TSecTm Tm=TSecTm::GetDtTm(YearN, MonthN, DayN);
906  Tm.AddHours(HourN);
907  Tm.AddMins(MinN);
908  Tm.AddSecs(SecN);
909  return Tm;
910 }
int GetInt() const
Definition: dt.h:578
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:160
TSecTm & AddSecs(const int &Secs)
Definition: tm.h:156
Definition: dt.h:201
Definition: tm.h:81
static TSecTm GetDtTm(const int &YearN, const int &MonthN, const int &DayN)
Definition: tm.cpp:938
Definition: dt.h:412
TSecTm & AddHours(const int &Hours)
Definition: tm.h:164
TStr TSecTm::GetDtTmSortFNmStr ( ) const

Definition at line 550 of file tm.cpp.

550  {
551  return
552  TInt::GetStr(GetYearN(), "%04d")+"-"+
553  TInt::GetStr(GetMonthN(), "%02d")+"-"+
554  TInt::GetStr(GetDayN(), "%02d")+"_"+
555  TInt::GetStr(GetHourN(), "%02d")+"-"+
556  TInt::GetStr(GetMinN(), "%02d")+"-"+
557  TInt::GetStr(GetSecN(), "%02d");
558 }
int GetMinN() const
Definition: tm.cpp:602
TStr GetStr() const
Definition: dt.h:1107
int GetYearN() const
Definition: tm.cpp:560
int GetMonthN() const
Definition: tm.cpp:566
int GetSecN() const
Definition: tm.cpp:608
int GetHourN() const
Definition: tm.cpp:596
int GetDayN() const
Definition: tm.cpp:578
TStr TSecTm::GetDtTmSortStr ( ) const

Definition at line 540 of file tm.cpp.

540  {
541  return
542  TInt::GetStr(GetYearN(), "%04d")+"/"+
543  TInt::GetStr(GetMonthN(), "%02d")+"/"+
544  TInt::GetStr(GetDayN(), "%02d")+" "+
545  TInt::GetStr(GetHourN(), "%02d")+":"+
546  TInt::GetStr(GetMinN(), "%02d")+":"+
547  TInt::GetStr(GetSecN(), "%02d");
548 }
int GetMinN() const
Definition: tm.cpp:602
TStr GetStr() const
Definition: dt.h:1107
int GetYearN() const
Definition: tm.cpp:560
int GetMonthN() const
Definition: tm.cpp:566
int GetSecN() const
Definition: tm.cpp:608
int GetHourN() const
Definition: tm.cpp:596
int GetDayN() const
Definition: tm.cpp:578
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 596 of file tm.cpp.

596  {
597  struct tm Tm;
598  IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
599  return Tm.tm_hour;
600 }
#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 650 of file tm.cpp.

650  {
651  static const int DayZero = TJulianDate::GetJulianDateN(1, 1, 1970);
652  if (TmUnit == tmu1Sec) { return AbsSecs; }
653  struct tm Time;
654  IAssert(IsDef() && GetTmStruct(AbsSecs(), Time));
655  switch (TmUnit) {
656  case tmu1Min : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, Time.tm_min, 0).GetAbsSecs()/60;
657  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);
658  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);
659  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);
660  case tmu1Hour : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, 0, 0).GetAbsSecs()/3600;
661  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);
662  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);
663  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);
664  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);
665  case tmuDay : return TJulianDate::GetJulianDateN(Time.tm_mday, Time.tm_mon+1, 1900+Time.tm_year) - DayZero;
666  case tmuWeek : return (TJulianDate::GetJulianDateN(Time.tm_mday, Time.tm_mon+1, 1900+Time.tm_year)-DayZero)/7;
667  case tmuMonth : return 12*(Time.tm_year-70)+Time.tm_mon+1;
668  case tmuYear : return Time.tm_year+1900;
669  default : Fail;
670  }
671  return TUInt::Mx;
672 }
#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:1154
#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:1182
TUInt AbsSecs
Definition: tm.h:83
int TSecTm::GetMinN ( ) const

Definition at line 602 of file tm.cpp.

602  {
603  struct tm Tm;
604  IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
605  return Tm.tm_min;
606 }
#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 566 of file tm.cpp.

566  {
567  struct tm Tm;
568  IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
569  return Tm.tm_mon+1;
570 }
#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 572 of file tm.cpp.

572  {
573  struct tm Tm;
574  IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
575  return TTmInfo::GetMonthNm(Tm.tm_mon+1, Loc);
576 }
#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:1184
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:1185
int TSecTm::GetSecN ( ) const

Definition at line 608 of file tm.cpp.

608  {
609  struct tm Tm;
610  IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
611  return Tm.tm_sec;
612 }
#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:602
TStr GetStr() const
Definition: dt.h:1107
int GetYearN() const
Definition: tm.cpp:560
int GetMonthN() const
Definition: tm.cpp:566
Definition: tm.h:13
Definition: tm.h:14
int GetSecN() const
Definition: tm.cpp:608
int GetHourN() const
Definition: tm.cpp:596
int GetDayN() const
Definition: tm.cpp:578
static TStr Fmt(const char *FmtStr,...)
Definition: dt.cpp:1599
Definition: tm.h:14
TStr TSecTm::GetTmMinStr ( ) const

Definition at line 530 of file tm.cpp.

530  {
531  if (IsDef()){
532  struct tm Tm;
533  IAssert(GetTmStruct(AbsSecs(), Tm));
534  return TStr::Fmt("%02d:%02d", Tm.tm_min, Tm.tm_sec);
535  } else {
536  return "Undef";
537  }
538 }
#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:1154
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 520 of file tm.cpp.

520  {
521  if (IsDef()){
522  struct tm Tm;
523  IAssert(GetTmStruct(AbsSecs(), Tm));
524  return TStr::Fmt("%02d:%02d:%02d", Tm.tm_hour, Tm.tm_min, Tm.tm_sec);
525  } else {
526  return "Undef";
527  }
528 }
#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:602
int GetYearN() const
Definition: tm.cpp:560
static PXmlTok New()
Definition: xml.h:212
int GetMonthN() const
Definition: tm.cpp:566
int GetSecN() const
Definition: tm.cpp:608
int GetHourN() const
Definition: tm.cpp:596
int GetDayN() const
Definition: tm.cpp:578
Definition: bd.h:196
int TSecTm::GetYearN ( ) const

Definition at line 560 of file tm.cpp.

560  {
561  struct tm Tm;
562  IAssert(IsDef() && GetTmStruct(AbsSecs(), Tm));
563  return Tm.tm_year+1900;
564 }
#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
TStr TSecTm::GetYmdTmStr2 ( ) const

Definition at line 514 of file tm.cpp.

514  {
515  struct tm Tm;
516  IAssert(GetTmStruct(AbsSecs(), Tm));
517  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);
518 }
#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 187 of file tm.h.

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

Definition at line 690 of file tm.cpp.

690  {
691  TSecTm ZeroWeekTm=GetZeroTm();
692  while (ZeroWeekTm.GetDayOfWeekN()!=TTmInfo::MonN){
693  ZeroWeekTm.AddDays(1);}
694  return ZeroWeekTm;
695 }
TSecTm & AddDays(const int &Days)
Definition: tm.h:168
int GetDayOfWeekN() const
Definition: tm.cpp:584
Definition: tm.h:81
static const int MonN
Definition: tm.h:47
static TSecTm GetZeroTm()
Definition: tm.h:187
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:1154
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:1161
TUInt AbsSecs
Definition: tm.h:83
TSecTm TSecTm::LoadTxt ( TILx Lx)
static

Definition at line 950 of file tm.cpp.

950  {
951  return TSecTm(Lx.GetInt());
952 }
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:1151
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 625 of file tm.cpp.

625  {
626  if (TmUnit == tmu1Sec) { return *this; }
627  struct tm Time;
628  IAssert(IsDef() && GetTmStruct(AbsSecs(), Time));
629  switch (TmUnit) {
630  case tmu1Min : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, Time.tm_min, 0);
631  case tmu10Min : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, 10*(Time.tm_min/10), 0);
632  case tmu15Min : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, 15*(Time.tm_min/15), 0);
633  case tmu30Min : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, 30*(Time.tm_min/30), 0);
634  case tmu1Hour : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, Time.tm_hour, 0, 0);
635  case tmu2Hour : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, 2*(Time.tm_hour/2), 0, 0);
636  case tmu4Hour : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, 4*(Time.tm_hour/4), 0, 0);
637  case tmu6Hour : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, 6*(Time.tm_hour/6), 0, 0);
638  case tmu12Hour : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, 12*(Time.tm_hour/12), 0, 0);
639  case tmuDay : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, Time.tm_mday, 0, 0, 0);
640  case tmuMonth : return TSecTm(Time.tm_year+1900, Time.tm_mon+1, 1, 0, 0, 0);
641  case tmuYear : return TSecTm(Time.tm_year+1900, 1, 1, 0, 0, 0);
642  case tmuWeek : { int dd=1, mm=1, yy=1;
643  // week starts on Thursday, since 1.1.1970 is Thursday
644  const int Day = TJulianDate::GetJulianDateN(Time.tm_mday, Time.tm_mon+1, 1900+Time.tm_year);
645  TJulianDate::GetCalendarDate(3+7*(Day/7), dd, mm, yy); return TSecTm(yy, mm, dd, 0, 0, 0); }
646  default : Fail;
647  }
648  return TSecTm();
649 }
#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:1162
TUInt AbsSecs
Definition: tm.h:83
void TSecTm::SaveTxt ( TOLx Lx) const

Definition at line 954 of file tm.cpp.

954  {
955  IAssert(int(AbsSecs) < TInt::Mx);
956  Lx.PutInt((int)AbsSecs);
957 }
#define IAssert(Cond)
Definition: bd.h:262
static const int Mx
Definition: dt.h:1049
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 170 of file tm.h.

170  {
171  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:1151
TSecTm& TSecTm::SubHours ( const int &  Hours)
inline

Definition at line 166 of file tm.h.

166  {
167  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:1151
TSecTm& TSecTm::SubMins ( const int &  Mins)
inline

Definition at line 162 of file tm.h.

162  {
163  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:1151
TSecTm& TSecTm::SubSecs ( const int &  Secs)
inline

Definition at line 158 of file tm.h.

158  {
159  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:1151
TSecTm& TSecTm::SubWeeks ( const int &  Weeks)
inline

Definition at line 174 of file tm.h.

174  {
175  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:1151
void TSecTm::Undef ( )
inline

Definition at line 124 of file tm.h.

static const uint Mx
Definition: dt.h:1154
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: