diff --git a/include/cppkafka/message.h b/include/cppkafka/message.h index 5702f3e..a307ea0 100644 --- a/include/cppkafka/message.h +++ b/include/cppkafka/message.h @@ -32,6 +32,7 @@ #include #include +#include #include #include #include "buffer.h" @@ -163,19 +164,19 @@ public: /** * Constructs a timestamp object */ - MessageTimestamp(int64_t timestamp, TimestampType type); + MessageTimestamp(std::chrono::milliseconds timestamp, TimestampType type); /** * Gets the timestamp value */ - int64_t get_timestamp() const; + std::chrono::milliseconds get_timestamp() const; /** * Gets the timestamp type */ TimestampType get_type() const; private: - int64_t timestamp_; + std::chrono::milliseconds timestamp_; TimestampType type_; }; diff --git a/src/message.cpp b/src/message.cpp index ecc71be..9c42c57 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -31,6 +31,8 @@ using std::string; +using std::chrono::milliseconds; + using boost::optional; using boost::none_t; @@ -104,7 +106,8 @@ optional Message::get_timestamp() const { if (timestamp == -1 || type == RD_KAFKA_TIMESTAMP_NOT_AVAILABLE) { return {}; } - return MessageTimestamp(timestamp, static_cast(type)); + return MessageTimestamp(milliseconds(timestamp), + static_cast(type)); } Message::operator bool() const { @@ -117,12 +120,12 @@ rd_kafka_message_t* Message::get_handle() const { // MessageTimestamp -MessageTimestamp::MessageTimestamp(int64_t timestamp, TimestampType type) +MessageTimestamp::MessageTimestamp(milliseconds timestamp, TimestampType type) : timestamp_(timestamp), type_(type) { } -int64_t MessageTimestamp::get_timestamp() const { +milliseconds MessageTimestamp::get_timestamp() const { return timestamp_; }