From 62f7d99b6e690a651cb64a70ba76637ede8452df Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Wed, 17 Oct 2012 22:44:21 -0400 Subject: [PATCH] update to time --- include/fc/time.hpp | 3 +++ src/time.cpp | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/include/fc/time.hpp b/include/fc/time.hpp index ff3bd9b..6771a37 100644 --- a/include/fc/time.hpp +++ b/include/fc/time.hpp @@ -1,6 +1,7 @@ #ifndef _FC_TIME_HPP_ #define _FC_TIME_HPP_ #include +#include namespace fc { class microseconds { @@ -26,6 +27,8 @@ namespace fc { static time_point now(); static time_point max() { return time_point( microseconds::max() ); } static time_point min() { return time_point(); } + operator fc::string()const; + const microseconds& time_since_epoch()const { return elapsed; } bool operator > ( const time_point& t )const { return elapsed._count > t.elapsed._count; } bool operator < ( const time_point& t )const { return elapsed._count < t.elapsed._count; } diff --git a/src/time.cpp b/src/time.cpp index b55d767..0574e4c 100644 --- a/src/time.cpp +++ b/src/time.cpp @@ -1,9 +1,18 @@ #include #include +#include namespace fc { namespace bch = boost::chrono; time_point time_point::now() { return time_point(microseconds(bch::duration_cast(bch::system_clock::now().time_since_epoch()).count())); } + 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<