fix bugs with time_point_sec

This commit is contained in:
Daniel Larimer 2013-07-23 13:00:40 -04:00
parent 9173154160
commit 2b8b606d08
2 changed files with 4 additions and 2 deletions

View file

@ -25,7 +25,7 @@ namespace fc {
inline void unpack( Stream& s, fc::time_point_sec& tp ) inline void unpack( Stream& s, fc::time_point_sec& tp )
{ {
uint32_t sec; uint32_t sec;
s.read( (char*)&usec, sizeof(sec) ); s.read( (char*)&sec, sizeof(sec) );
tp = fc::time_point() + fc::seconds(sec); tp = fc::time_point() + fc::seconds(sec);
} }

View file

@ -60,16 +60,18 @@ namespace fc {
time_point_sec() time_point_sec()
:utc_seconds(0){} :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 ){} :utc_seconds( t.time_since_epoch().count() / 1000000ll ){}
operator time_point()const { return time_point( fc::seconds( utc_seconds) ); } 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 ) time_point_sec operator = ( const fc::time_point& t )
{ {
utc_seconds = t.time_since_epoch().count() / 1000000ll; utc_seconds = t.time_since_epoch().count() / 1000000ll;
return *this; return *this;
} }
friend bool operator < ( const time_point_sec& a, const time_point_sec& b ) { return a.utc_seconds < b.utc_seconds; }
private: private:
uint32_t utc_seconds; uint32_t utc_seconds;