1 #ifndef PROTON_TIMESTAMP_HPP
2 #define PROTON_TIMESTAMP_HPP
23 #include "./duration.hpp"
25 #include <proton/type_compat.h>
32 class timestamp :
private internal::comparable<timestamp> {
55 inline bool operator==(timestamp x, timestamp y) {
return x.milliseconds() == y.milliseconds(); }
56 inline bool operator<(timestamp x, timestamp y) {
return x.milliseconds() < y.milliseconds(); }
58 inline timestamp operator+(timestamp ts, duration d) {
return timestamp(ts.milliseconds() + d.milliseconds()); }
59 inline duration operator-(timestamp t0, timestamp t1) {
return duration(t0.milliseconds() - t1.milliseconds()); }
60 inline timestamp operator+(duration d, timestamp ts) {
return ts + d; }
64 PN_CPP_EXTERN std::ostream&
operator<<(std::ostream&, timestamp);
68 #endif // PROTON_TIMESTAMP_HPP
timestamp & operator=(numeric_type ms)
Assign from milliseconds.
Definition: timestamp.hpp:44
std::ostream & operator<<(std::ostream &, const binary &)
Print a binary value.
numeric_type milliseconds() const
Get milliseconds.
Definition: timestamp.hpp:47
timestamp(numeric_type ms=0)
Construct from milliseconds.
Definition: timestamp.hpp:41
static timestamp now()
The current wall-clock time.
int64_t numeric_type
A numeric type holding a milliseconds value.
Definition: timestamp.hpp:35
A 64-bit timestamp in milliseconds since the Unix epoch.
Definition: timestamp.hpp:32