#include <TimeVal.h>
|
void | init (long, long, int) |
| Internal initialization common to most constructors. More...
|
|
Definition at line 30 of file TimeVal.h.
◆ anonymous enum
Enumerator |
---|
gmt | GMT.
|
loc | Local Time Zone.
|
Definition at line 33 of file TimeVal.h.
◆ TimeVal() [1/5]
ASSA::TimeVal::TimeVal |
( |
| ) |
|
|
inline |
◆ TimeVal() [2/5]
ASSA::TimeVal::TimeVal |
( |
long |
sec_, |
|
|
long |
msec_ |
|
) |
| |
|
inline |
Constructor from seconds/microseconds pair.
Definition at line 203 of file TimeVal.h.
References gmt, and init().
◆ TimeVal() [3/5]
ASSA::TimeVal::TimeVal |
( |
double |
d_ | ) |
|
|
inline |
Constructor from double.
Definition at line 210 of file TimeVal.h.
215 tv_usec = (long) ((d_ -
double(l))*1000000.0);
References normalize().
◆ TimeVal() [4/5]
ASSA::TimeVal::TimeVal |
( |
const timeval & |
tv_ | ) |
|
|
inline |
Constructor from struct timeval
.
Definition at line 221 of file TimeVal.h.
223 init (tv_.tv_sec, tv_.tv_usec,
gmt);
References gmt, and init().
◆ TimeVal() [5/5]
ASSA::TimeVal::TimeVal |
( |
const TimeVal & |
tv_ | ) |
|
|
inline |
Copy constructor.
Definition at line 228 of file TimeVal.h.
230 init (tv_.tv_sec, tv_.tv_usec, tv_.m_tz);
References init(), and m_tz.
◆ dump_to_log()
void TimeVal::dump_to_log |
( |
const string & |
name_ = "" | ) |
const |
Dump value of struct timeval to the log file with mask TRACE = DBG_APP15.
Definition at line 227 of file TimeVal.cpp.
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"));
References DL, fmt_mm_ss_mls(), ASSA::Singleton< Logger >::get_instance(), millisec(), msec(), ASSA::REACT, sec(), and trace.
◆ fmt_hh_mm_ss()
string ASSA::TimeVal::fmt_hh_mm_ss |
( |
| ) |
const |
|
inline |
Format timeval structure in readable format HH:MM:SS.
Definition at line 248 of file TimeVal.h.
References fmtString().
◆ fmt_hh_mm_ss_mls()
string TimeVal::fmt_hh_mm_ss_mls |
( |
| ) |
const |
Format timeval structure in readable format HH:MM:SS.MLS.
Definition at line 170 of file TimeVal.cpp.
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 ());
References gmt, m_tz, and millisec().
◆ fmt_mm_ss()
string ASSA::TimeVal::fmt_mm_ss |
( |
| ) |
const |
|
inline |
Format timeval structure in readable format MM:SS.
Definition at line 255 of file TimeVal.h.
References fmtString().
◆ fmt_mm_ss_mls()
string TimeVal::fmt_mm_ss_mls |
( |
| ) |
const |
Format timeval structure in readable format MM:SS.MLS.
Definition at line 189 of file TimeVal.cpp.
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 ());
References gmt, m_tz, and millisec().
Referenced by ASSA::Timer::dump(), and dump_to_log().
◆ fmt_ss_mls()
string TimeVal::fmt_ss_mls |
( |
| ) |
const |
Format timeval structure in readable format SS.MLS.
Definition at line 208 of file TimeVal.cpp.
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 ());
References gmt, m_tz, and millisec().
◆ fmtString()
string TimeVal::fmtString |
( |
const char * |
fmt_ = NULL | ) |
const |
Format timeval structure into readable format.
Default format is CCYY/DDD HH:MM:SS.MMM which is de fasco for the software. To get something different, pass fmt_ format string as specified by strftime(3). Popular format is "%c" which will return something like: "Fri Oct 1 10:54:27 1999". Note that timezone aspect of formatting time is controlled by tz() member function.
- Parameters
-
fmt_ | Format string as in strftime(3) |
- Returns
- Formatted string.
Definition at line 146 of file TimeVal.cpp.
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);
References gmt, and m_tz.
Referenced by ASSA::Logger_Impl::add_timestamp(), ASSA::Timer::dump(), ASSA::TimerQueue::expire(), fmt_hh_mm_ss(), fmt_mm_ss(), and ASSA::Reactor::registerTimerHandler().
◆ gettimeofday()
◆ init()
void ASSA::TimeVal::init |
( |
long |
s_, |
|
|
long |
ms_, |
|
|
int |
tz_ |
|
) |
| |
|
inlineprotected |
◆ millisec()
long ASSA::TimeVal::millisec |
( |
| ) |
const |
|
inline |
◆ msec() [1/2]
void ASSA::TimeVal::msec |
( |
long |
msec_ | ) |
|
|
inline |
◆ msec() [2/2]
long ASSA::TimeVal::msec |
( |
void |
| ) |
const |
|
inline |
◆ normalize()
void TimeVal::normalize |
( |
| ) |
|
|
private |
◆ operator double()
ASSA::TimeVal::operator double |
( |
| ) |
const |
|
inline |
Implicit conversion to double.
Definition at line 234 of file TimeVal.h.
236 return tv_sec + tv_usec / 1000000.0;
◆ operator+=()
Addition.
Definition at line 74 of file TimeVal.cpp.
76 tv_sec += rhs_.tv_sec;
77 tv_usec += rhs_.tv_usec;
83 else if (tv_sec >= 1 && tv_usec < 0) {
References normalize(), and ONE_SECOND.
◆ operator-=()
◆ operator<()
bool ASSA::TimeVal::operator< |
( |
const TimeVal & |
rhs_ | ) |
const |
|
inline |
Comparison.
Definition at line 292 of file TimeVal.h.
294 return (tv_sec < rhs_.tv_sec
295 || (tv_sec == rhs_.tv_sec && tv_usec < rhs_.tv_usec) ) ;
◆ operator=()
◆ operator==()
bool ASSA::TimeVal::operator== |
( |
const TimeVal & |
rhs_ | ) |
const |
|
inline |
Equality.
Definition at line 300 of file TimeVal.h.
302 return !(*
this < rhs_ || rhs_ < *
this);
◆ sec() [1/2]
void ASSA::TimeVal::sec |
( |
long |
sec_ | ) |
|
|
inline |
◆ sec() [2/2]
long ASSA::TimeVal::sec |
( |
void |
| ) |
const |
|
inline |
◆ tz() [1/2]
void ASSA::TimeVal::tz |
( |
int |
tz_ | ) |
|
|
inline |
◆ tz() [2/2]
int ASSA::TimeVal::tz |
( |
void |
| ) |
const |
|
inline |
◆ zeroTime()
static TimeVal ASSA::TimeVal::zeroTime |
( |
| ) |
|
|
inlinestatic |
◆ operator!=
Comparison.
Definition at line 312 of file TimeVal.h.
314 return !( lhs_ == rhs_ );
◆ operator+
◆ operator-
◆ operator<=
Comparison.
Definition at line 318 of file TimeVal.h.
320 return !(rhs_ < lhs_);
◆ operator>
◆ operator>=
Comparison.
Definition at line 324 of file TimeVal.h.
326 return !(lhs_ < rhs_);
◆ m_tz
◆ m_zero
The documentation for this class was generated from the following files: