#include "PBUtils.h" #include #include #include #include namespace bts { namespace utils { namespace pb { std::string to_string(google::protobuf::Message const &msg) { std::string result; google::protobuf::TextFormat::PrintToString(msg, &result); return result; } google::protobuf::Timestamp to_timestamp(datetime::PTime const &t) { google::protobuf::Timestamp gts; using namespace boost::posix_time; using namespace boost::gregorian; ptime timet_start(date(1970, 1, 1)); time_duration diff = t - timet_start; gts.set_seconds(diff.total_seconds()); gts.set_nanos( diff.total_nanoseconds() - (diff.total_seconds() * 1000 * 1000 * 1000)); return gts; } } // namespace pb } // namespace utils } // namespace bts