24 #ifndef __UTILS_TIME_TIME_H_
25 #define __UTILS_TIME_TIME_H_
43 double res = a.tv_sec - b.tv_sec + (a.tv_usec - b.tv_usec) / 1000000.0;
59 const long int b_sec,
const long int b_usec)
62 double res = a_sec - b_sec + (a_usec - b_usec) / 1000000.0;
74 return (
long)round(sec * 1000000.);
86 return (a.tv_sec - b.tv_sec) * 1000000 + (a.tv_usec - b.tv_usec);
96 Time(
const timeval* tv);
97 Time(
long sec,
long usec,
Clock *clock = 0);
110 long get_sec()
const {
return __time.tv_sec; }
111 long get_msec()
const {
return __time.tv_usec / 1000; }
113 long get_nsec()
const {
return __time.tv_usec * 1000; }
115 { sec = __time.tv_sec; usec = __time.tv_usec; }
116 bool is_zero()
const {
return (__time.tv_sec == 0) && (__time.tv_usec == 0); }
119 void set_time(
long int sec,
long int usec);
127 void add(
double seconds);
163 const char *
str(
bool utc =
false)
const;
164 void str_r(
char *s,
bool utc =
false);
171 mutable char *__timestr;