32 #include <sys/types.h> 38 #include "rnr/rnrconfig.h" 53 extern std::ostream &
operator<<(std::ostream &os,
const timespec &obj);
74 extern timespec
now();
84 extern int now(timespec &ts);
93 extern double toFp(
const timespec &ts);
102 extern timespec
toTs(
const double &t);
111 extern bool isSet(
const timespec &a);
118 extern void clear(timespec &ts);
130 extern timespec
add(
const timespec &a,
const timespec &b);
140 inline timespec
operator+(
const timespec &a,
const timespec &b)
155 extern timespec
sub(
const timespec &a,
const timespec &b);
165 inline timespec
operator-(
const timespec &a,
const timespec &b)
178 extern timespec
normalize(
const timespec &a);
212 Time(
const double &
t);
472 return (
m_tsTime.tv_sec == b.tv_sec) &&
612 std::string calendarTime(
const int resSec = 0)
const;
614 friend std::ostream &
operator<<(std::ostream &os,
const Time &obj);
629 extern std::ostream &
operator<<(std::ostream &os,
const Time &obj);
635 #endif // _RNR_TIME_H Time & operator=(const Time &b)
this = b
bool isSet(const timespec &a)
Check if timespec is set.
timespec m_tsTime
time in timespec format
double m_fpTime
time in floating point format
friend Time operator-(Time a, const timespec &b)
c = a - b
bool operator<(const Time &b)
this < b
friend Time operator+(Time a, const double &b)
c = a + b
timespec ts()
Get this object's value in timespec format.
bool operator<=(const Time &b)
this <= b
bool operator<(const double &b)
this < b
double getResolution()
Get the CLOCK_REALTIME resolution.
friend std::ostream & operator<<(std::ostream &os, const Time &obj)
Time insertion operator.
double t()
Get this object's value as a floating point number of seconds and fractions of a second.
friend Time operator+(Time a, const timespec &b)
c = a + b
Time & operator-=(const Time &b)
this -= b
void clear()
Clear this object's time.
double toFp(const timespec &ts)
Convert timespec to floating point number equivalent.
bool isSet()
Check if this object's time is set.
bool operator<=(const double &b)
this <= b
bool operator>=(const Time &b)
this >= b
friend Time operator+(Time a, const Time &b)
c = a + b
void clear(timespec &ts)
Clear this object's time.
double now()
Get the current time, indentified by CLOCK_REALTIME, since the last Epoch.
timespec sub(const timespec &a, const timespec &b)
Subtract two timespecs.
bool operator==(const double &b)
this == b
bool operator>=(const double &b)
this >= b
timespec toTs(const double &t)
Convert floating point seconds to timespec equivalent.
bool operator>(const double &b)
this > b
double markNow()
Mark the current time, indentified by CLOCK_REALTIME, since the last Epoch.
timespec add(const timespec &a, const timespec &b)
Add two timespecs.
bool operator==(const timespec &b)
this == b
bool operator>(const Time &b)
this > b
bool operator==(const Time &b)
this == b
timespec now()
Get the current time, indentified by CLOCK_REALTIME, since the last Epoch.
Time()
Default constructor.
Time & operator+=(const Time &b)
this += b
friend Time operator-(Time a, const Time &b)
c = a - b
Time & operator*=(const double &b)
this *= b
timespec operator-(const timespec &a, const timespec &b)
a - b
const long MILLION
1,000,000
friend Time operator*(Time a, const double &b)
c = a * b
timespec normalize(const timespec &a)
Normalize the timespec.
bool operator>=(const timespec &b)
this >= b
const long long BILLION
1,000,000,000
std::ostream & operator<<(std::ostream &os, const timespec &obj)
A timespec insertion operator.
bool operator<=(const timespec &b)
this <= b
friend Time operator-(Time a, const double &b)
c = a - b
timespec operator+(const timespec &a, const timespec &b)
a + b