Add time_point_sec::to_iso_{extended_}string()
This commit is contained in:
parent
24ba357b0d
commit
48837f3116
3 changed files with 17 additions and 3 deletions
|
|
@ -109,6 +109,9 @@ namespace fc {
|
|||
friend microseconds operator - ( const time_point_sec& t, const time_point_sec& m ) { return time_point(t) - time_point(m); }
|
||||
friend microseconds operator - ( const time_point& t, const time_point_sec& m ) { return time_point(t) - time_point(m); }
|
||||
|
||||
fc::string to_iso_string()const;
|
||||
fc::string to_iso_extended_string()const;
|
||||
|
||||
private:
|
||||
uint32_t utc_seconds;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
#include <fc/thread/scoped_lock.hpp>
|
||||
#include <fc/thread/thread.hpp>
|
||||
#include <fc/variant.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <iomanip>
|
||||
#include <queue>
|
||||
|
|
@ -36,8 +35,7 @@ namespace fc {
|
|||
|
||||
string timestamp_to_string( const time_point_sec& timestamp )
|
||||
{
|
||||
auto ptime = boost::posix_time::from_time_t( time_t ( timestamp.sec_since_epoch() ) );
|
||||
return boost::posix_time::to_iso_string( ptime );
|
||||
return timestamp.to_iso_string();
|
||||
}
|
||||
|
||||
time_point_sec string_to_timestamp( const string& str )
|
||||
|
|
|
|||
13
src/time.cpp
13
src/time.cpp
|
|
@ -29,6 +29,19 @@ namespace fc {
|
|||
}
|
||||
FC_RETHROW_EXCEPTIONS(warn, "unable to convert ISO-formatted string to fc::time_point")
|
||||
}
|
||||
|
||||
fc::string time_point_sec::to_iso_string()const
|
||||
{
|
||||
const auto ptime = boost::posix_time::from_time_t( time_t ( sec_since_epoch() ) );
|
||||
return boost::posix_time::to_iso_string( ptime );
|
||||
}
|
||||
|
||||
fc::string time_point_sec::to_iso_extended_string()const
|
||||
{
|
||||
const auto ptime = boost::posix_time::from_time_t( time_t ( sec_since_epoch() ) );
|
||||
return boost::posix_time::to_iso_extended_string( ptime );
|
||||
}
|
||||
|
||||
void to_variant( const fc::time_point& t, variant& v ) {
|
||||
v = fc::string(t);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue