From 2b8b606d0868b38192da6a66cd738940711e278d Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Tue, 23 Jul 2013 13:00:40 -0400 Subject: [PATCH] fix bugs with time_point_sec --- include/fc/io/raw.hpp | 2 +- include/fc/time.hpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/fc/io/raw.hpp b/include/fc/io/raw.hpp index e187ff8..65511d1 100644 --- a/include/fc/io/raw.hpp +++ b/include/fc/io/raw.hpp @@ -25,7 +25,7 @@ namespace fc { inline void unpack( Stream& s, fc::time_point_sec& tp ) { uint32_t sec; - s.read( (char*)&usec, sizeof(sec) ); + s.read( (char*)&sec, sizeof(sec) ); tp = fc::time_point() + fc::seconds(sec); } diff --git a/include/fc/time.hpp b/include/fc/time.hpp index 06c5970..ffb6a9d 100644 --- a/include/fc/time.hpp +++ b/include/fc/time.hpp @@ -60,16 +60,18 @@ namespace fc { time_point_sec() :utc_seconds(0){} - time_point_sec( const time_point& t = time_point() ) + time_point_sec( const time_point& t ) :utc_seconds( t.time_since_epoch().count() / 1000000ll ){} operator time_point()const { return time_point( fc::seconds( utc_seconds) ); } + uint32_t sec_since_epoch()const { return utc_seconds; } time_point_sec operator = ( const fc::time_point& t ) { utc_seconds = t.time_since_epoch().count() / 1000000ll; return *this; } + friend bool operator < ( const time_point_sec& a, const time_point_sec& b ) { return a.utc_seconds < b.utc_seconds; } private: uint32_t utc_seconds;