34 #define EPOCHFILETIME (116444736000000000i64)
36 #define EPOCHFILETIME (116444736000000000LL)
54 GetSystemTimeAsFileTime(&ft);
55 li.LowPart = ft.dwLowDateTime;
56 li.HighPart = ft.dwHighDateTime;
60 tv.tv_sec = (long)(t / 1000000);
61 tv.tv_usec = (long)(t % 1000000);
76 tv_sec += rhs_.tv_sec;
77 tv_usec += rhs_.tv_usec;
83 else if (tv_sec >= 1 && tv_usec < 0) {
95 tv_sec -= rhs_.tv_sec;
96 tv_usec -= rhs_.tv_usec;
129 if (tv_sec >= 1 && tv_usec < 0) {
133 else if (tv_sec < 0 && tv_usec > 0) {
153 ct = *( localtime ((
const time_t*) &tv_sec) );
155 ct = *( gmtime ((
const time_t*) &tv_sec) );
158 strftime (buf, 80,
"%Y/%j %H:%M:%S", &ct);
159 sprintf (buf + strlen(buf),
160 ".%03ld", (tv_usec %1000000)/1000);
163 strftime(buf, 80, fmt_, &ct);
177 ct = *( localtime ((
const time_t*) &tv_sec) );
179 ct = *( gmtime ((
const time_t*) &tv_sec) );
181 strftime (buf, 80,
"%H:%M:%S", &ct);
182 sprintf (buf + strlen(buf),
".%03ld",
millisec ());
196 ct = *( localtime ((
const time_t*) &tv_sec) );
198 ct = *( gmtime ((
const time_t*) &tv_sec) );
200 strftime (buf, 80,
"%M:%S", &ct);
201 sprintf (buf + strlen(buf),
".%03ld",
millisec ());
215 ct = *( localtime ((
const time_t*) &tv_sec) );
217 ct = *( gmtime ((
const time_t*) &tv_sec) );
219 strftime (buf, 80,
"%S", &ct);
220 sprintf (buf + strlen(buf),
".%03ld",
millisec ());
229 static const char self []=
"TimeVal::dump_to_log";
trace(
self);
233 DL((
REACT,
"=== TimeVal %s ===\n", var_name_.c_str ()));
235 DL((
REACT,
"tv_sec = %d, tv_msec = %d, tv_mls = %d\n",
237 DL((
REACT,
"(double) = %7.4f\n",
double (*
this)));
238 DL((
REACT,
"==================\n"));
An abstraction to message logging facility.
#define trace(s)
trace() is used to trace function call chain in C++ program.
#define DL(X)
A macro for writing debug message to the Logger.
static const long ONE_SECOND
Class TimeVal is a wrapper around UNIX timeval structure.
static Logger * get_instance()
Return an instance of templated class T.
static TimeVal m_zero
Zero time value.
string fmtString(const char *fmt_=NULL) const
Format timeval structure into readable format.
void normalize()
Normalization after arithmetic operation.
string fmt_ss_mls() const
Format timeval structure in readable format SS.MLS.
string fmt_mm_ss_mls() const
Format timeval structure in readable format MM:SS.MLS.
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).
void dump_to_log(const string &name_="") const
Dump value of struct timeval to the log file with mask TRACE = DBG_APP15.
static TimeVal gettimeofday()
Shields off underlying OS differences in getting current time.
long sec(void) const
Get secons.
TimeVal & operator-=(const TimeVal &rhs_)
Substraction.
string fmt_hh_mm_ss_mls() const
Format timeval structure in readable format HH:MM:SS.MLS.
@ REACT
Class Reactor/PrioriyQueue messages