1 #ifndef __TIME_GENERAL_H__ 2 #define __TIME_GENERAL_H__ 14 bool SetFromTimeStr(
const char * str,
Time_Clock & outtime);
15 std::string GetTimeStr(
const Time_Clock & intime);
27 TimeDif(time2.GetTval(), time1.GetTval(), ans);
28 return Time_Span(ans);
40 TimeDif(Time_Span.GetTval(), time1.GetTval(), ans);
53 TimeAdd(time1.GetTval(), Time_Span.GetTval(), ans);
64 _my_time.tv_usec += Time_Span._my_time.tv_usec;
65 _my_time.tv_sec += Time_Span._my_time.tv_sec;
66 NormalizeTime(_my_time);
91 return TimeDifference(tm, ts);
101 _my_time.tv_usec -= Time_Span._my_time.tv_usec;
102 _my_time.tv_sec -= Time_Span._my_time.tv_sec;
103 NormalizeTime(_my_time);
115 return TimeDifference(tm1, tm2);
123 inline std::string GetTimeStr(
const Time_Clock & intime)
125 static std::string ts;
128 if (prev_time != intime || ts.empty())
130 ts = intime.
Format(
"%Y-%m-%d %H:%M:%S");
141 inline std::string GetTimeStr()
152 inline bool SetFromTimeStr(
const char * str,
Time_Clock & outtime)
161 if (sscanf(str,
"%d-%d-%d %d:%d:%d", &year, &month, &day, &hour, &min, &sec) != 6)
164 outtime.
Set(year, month, day, hour, min, sec);
168 #endif //__TIME_GENERAL_H__ std::string Format(const char *pFormat) const
Used to allow access to the "C" library strftime functions.
const Time_Clock & operator+=(const Time_Span &Time_Span)
Return type : inline const Argument : Time_Span &Time_Span.
const Time_Clock & operator-=(const Time_Span &Time_Span)
Return type : inline const Argument : Time_Span &Time_Span.
void Set(int nYear, int nMonth, int nDay, int nHour, int nMin, int nSec, unsigned long microseconds=0, int nDST=-1)
Return type : inline Argument : int nYear Argument : int nMonth Argument : int nDay Argument : int nH...
static Time_Clock GetCurrentTime()
The Default no param constructor.