Convert boost exceptions caught while parsing fc::time_point strings into fc::exception
This commit is contained in:
parent
0d1eb8b78c
commit
07f131336f
1 changed files with 10 additions and 4 deletions
|
|
@ -5,6 +5,7 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <fc/string.hpp>
|
#include <fc/string.hpp>
|
||||||
#include <fc/io/sstream.hpp>
|
#include <fc/io/sstream.hpp>
|
||||||
|
#include <fc/exception/exception.hpp>
|
||||||
|
|
||||||
namespace fc {
|
namespace fc {
|
||||||
namespace bch = boost::chrono;
|
namespace bch = boost::chrono;
|
||||||
|
|
@ -18,11 +19,16 @@ namespace fc {
|
||||||
|
|
||||||
return boost::posix_time::to_iso_string( boost::posix_time::from_time_t(tt) + boost::posix_time::microseconds( elapsed._count % 1000000 ) );
|
return boost::posix_time::to_iso_string( boost::posix_time::from_time_t(tt) + boost::posix_time::microseconds( elapsed._count % 1000000 ) );
|
||||||
}
|
}
|
||||||
time_point time_point::from_iso_string( const fc::string& s ) {
|
time_point time_point::from_iso_string( const fc::string& s )
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
auto pt = boost::posix_time::from_iso_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() ));
|
//return fc::time_point(fc::seconds( (pt - boost::posix_time::from_time_t(0)).total_seconds() ));
|
||||||
return fc::time_point(fc::microseconds( (pt - boost::posix_time::from_time_t(0)).total_microseconds() ));
|
return fc::time_point(fc::microseconds( (pt - boost::posix_time::from_time_t(0)).total_microseconds() ));
|
||||||
}
|
}
|
||||||
|
FC_RETHROW_EXCEPTIONS(warn, "unable to convert ISO-formatted string to fc::time_point")
|
||||||
|
}
|
||||||
void to_variant( const fc::time_point& t, variant& v ) {
|
void to_variant( const fc::time_point& t, variant& v ) {
|
||||||
v = fc::string(t);
|
v = fc::string(t);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue