45 TimeVal (
long sec_,
long msec_);
61 operator double ()
const;
64 void sec (
long sec_) { tv_sec = sec_; }
67 long sec (
void)
const {
return tv_sec; }
70 void msec (
long msec_) { tv_usec = msec_; }
73 long msec (
void)
const {
return tv_usec; }
128 string fmtString (
const char* fmt_ = NULL)
const;
167 void init (
long,
long,
int);
186 init (
long s_,
long ms_,
int tz_)
203 TimeVal (
long sec_,
long msec_)
215 tv_usec = (long) ((d_ -
double(l))*1000000.0);
223 init (tv_.tv_sec, tv_.tv_usec,
gmt);
230 init (tv_.tv_sec, tv_.tv_usec, tv_.
m_tz);
234 TimeVal::operator double ()
const
236 return tv_sec + tv_usec / 1000000.0;
243 return (
msec () % 1000000) / 1000;
268 init (tv_.tv_sec, tv_.tv_usec, tv_.
m_tz);
294 return (tv_sec < rhs_.tv_sec
295 || (tv_sec == rhs_.tv_sec && tv_usec < rhs_.tv_usec) ) ;
302 return !(*
this < rhs_ || rhs_ < *
this);
314 return !( lhs_ == rhs_ );
320 return !(rhs_ < lhs_);
326 return !(lhs_ < rhs_);
void tz(int tz_)
Set timezone.
static TimeVal m_zero
Zero time value.
string fmtString(const char *fmt_=NULL) const
Format timeval structure into readable format.
string fmt_mm_ss() const
Format timeval structure in readable format MM:SS.
void normalize()
Normalization after arithmetic operation.
int tz(void) const
Get timezone.
TimeVal & operator=(const TimeVal &tv_)
string fmt_ss_mls() const
Format timeval structure in readable format SS.MLS.
static TimeVal zeroTime()
Static that returns zero timeval: {0,0}.
friend TimeVal operator+(const TimeVal &lhs_, const TimeVal &rhs_)
Addition.
friend bool operator>=(const TimeVal &lhs_, const TimeVal &rhs_)
Comparison.
friend bool operator>(const TimeVal &lhs_, const TimeVal &rhs_)
Comparison.
friend bool operator<=(const TimeVal &lhs_, const TimeVal &rhs_)
Comparison.
string fmt_mm_ss_mls() const
Format timeval structure in readable format MM:SS.MLS.
friend bool operator!=(const TimeVal &lhs_, const TimeVal &rhs_)
Comparison.
string fmt_hh_mm_ss() const
Format timeval structure in readable format HH:MM:SS.
long msec(void) const
Get microseconds.
TimeVal & operator+=(const TimeVal &rhs_)
Addition.
long millisec() const
Convert tv_usec's microseconds (=1/1,000,000 sec) to milliseconds (=1/1,000 sec).
friend TimeVal operator-(const TimeVal &lhs_, const TimeVal &rhs_)
Substraction.
void init(long, long, int)
Internal initialization common to most constructors.
void dump_to_log(const string &name_="") const
Dump value of struct timeval to the log file with mask TRACE = DBG_APP15.
void sec(long sec_)
Set seconds.
bool operator<(const TimeVal &rhs_) const
Comparison.
TimeVal()
Default constructor.
static TimeVal gettimeofday()
Shields off underlying OS differences in getting current time.
long sec(void) const
Get secons.
TimeVal & operator-=(const TimeVal &rhs_)
Substraction.
bool operator==(const TimeVal &rhs_) const
Equality.
void msec(long msec_)
Set microseconds.
string fmt_hh_mm_ss_mls() const
Format timeval structure in readable format HH:MM:SS.MLS.
bool operator!=(const TimeVal &lhs_, const TimeVal &rhs_)
bool operator>=(const TimeVal &lhs_, const TimeVal &rhs_)
TimeVal operator+(const TimeVal &lhs_, const TimeVal &rhs_)
bool operator>(const TimeVal &lhs_, const TimeVal &rhs_)
TimeVal operator-(const TimeVal &lhs_, const TimeVal &rhs_)
bool operator<=(const TimeVal &lhs_, const TimeVal &rhs_)