peerplays-fc/src/time.cpp

19 lines
555 B
C++
Raw Normal View History

2012-09-08 02:50:37 +00:00
#include <boost/chrono/system_clocks.hpp>
#include <fc/time.hpp>
2012-10-18 02:44:21 +00:00
#include <sstream>
2012-09-08 02:50:37 +00:00
namespace fc {
namespace bch = boost::chrono;
time_point time_point::now() {
return time_point(microseconds(bch::duration_cast<bch::microseconds>(bch::system_clock::now().time_since_epoch()).count()));
}
2012-10-18 02:44:21 +00:00
time_point::operator fc::string()const {
bch::system_clock::time_point tp;
tp += bch::microseconds( elapsed._count);
time_t tt = bch::system_clock::to_time_t(tp);
std::stringstream ss;
ss<<tt;
return ss.str();
}
2012-09-08 02:50:37 +00:00
}