time /string conversion
This commit is contained in:
parent
21ef2d11e9
commit
cc44e8bbe0
4 changed files with 15 additions and 1 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
#include <fc/shared_ptr.hpp>
|
||||
#include <fc/filesystem.hpp>
|
||||
#include <fc/iostream.hpp>
|
||||
|
||||
namespace fc {
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ namespace fc {
|
|||
static time_point min() { return time_point(); }
|
||||
operator fc::string()const;
|
||||
|
||||
static time_point from_iso_string( const fc::string& s );
|
||||
|
||||
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; }
|
||||
|
|
|
|||
11
src/time.cpp
11
src/time.cpp
|
|
@ -14,4 +14,15 @@ namespace fc {
|
|||
time_t tt = bch::system_clock::to_time_t(tp);
|
||||
return boost::posix_time::to_iso_string( boost::posix_time::from_time_t(tt) );
|
||||
}
|
||||
time_point time_point::from_iso_string( const fc::string& s ) {
|
||||
auto pt = boost::posix_time::from_iso_string(s);
|
||||
return fc::time_point(fc::seconds( (pt - boost::posix_time::from_time_t(0)).total_seconds() ));
|
||||
}
|
||||
class value;
|
||||
void pack( fc::value& v, const fc::time_point& t ) {
|
||||
v = fc::string(t);
|
||||
}
|
||||
void unpack( const fc::value& v, fc::time_point& t ) {
|
||||
t = fc::time_point::from_iso_string(v.cast<fc::string>());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
2
vendor/CMakeLists.txt
vendored
2
vendor/CMakeLists.txt
vendored
|
|
@ -1,3 +1,3 @@
|
|||
add_subdirectory( libssh2-1.4.2 )
|
||||
#add_subdirectory( zlib-1.2.7)
|
||||
add_subdirectory( sigar )
|
||||
#add_subdirectory( sigar )
|
||||
|
|
|
|||
Loading…
Reference in a new issue