Apache Qpid - AMQP Messaging for Java JMS, C++, Python, Ruby, and .NET | Apache Qpid Documentation |
Class to represent an instant in time. More...
#include <qpid/sys/Time.h>
Public Member Functions | |
AbsTime () | |
AbsTime (const AbsTime &time0, const Duration &duration) | |
bool | operator== (const AbsTime &t) const |
Static Public Member Functions | |
static AbsTime | now () |
static AbsTime | FarFuture () |
static AbsTime | Epoch () |
Friends | |
bool | operator< (const AbsTime &a, const AbsTime &b) |
bool | operator> (const AbsTime &a, const AbsTime &b) |
std::ostream & | operator<< (std::ostream &, const AbsTime &) |
Class to represent an instant in time.
The time resolution is in nanosecs, and this is held with 64 bits giving a total time span from about 25 million years ago to 25 million years hence. As an aside the internal time can sensibly be negative meaning before the epoch (probably 1/1/1970 although this class doesn't care).
The AbsTime class is a value class and so you don't need to add any accessors to its internal state. If you think you want to replace its value, you need to construct a new AbsTime and assign it, viz:
AbsTime when = now(); ... when = AbsTime(when, 2*TIME_SEC); // Advance timer 2 secs
AbsTime is not intended to be used to represent calendar dates/times but you can construct a Duration since the Unix Epoch, 1970-1-1-00:00, so that you can convert to a date/time if needed:
int64_t nanosec_since_epoch = Duration(EPOCH, now());
There are some sensible operations that are currently missing from AbsTime, but nearly all that's needed can be done with a mixture of AbsTimes and Durations.
For example, convenience operators to add a Duration and AbsTime returning an AbsTime would fit here (although you can already perform the operation with one of the AbsTime constructors). However trying to add 2 AbsTimes doesn't make sense.
Definition at line 72 of file Time.h.
static AbsTime qpid::sys::AbsTime::Epoch | ( | ) | [static] |
static AbsTime qpid::sys::AbsTime::FarFuture | ( | ) | [static] |
static AbsTime qpid::sys::AbsTime::now | ( | ) | [static] |
Referenced by qpid::sys::Duration::Duration().
bool qpid::sys::AbsTime::operator== | ( | const AbsTime & | t | ) | const [inline] |
std::ostream& operator<< | ( | std::ostream & | , | |
const AbsTime & | ||||
) | [friend] |