Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
fc::time_point Class Reference

#include <time.hpp>

Public Member Functions

constexpr time_point (microseconds e=microseconds())
 
 operator fc::string () const
 
constexpr const microsecondstime_since_epoch () const
 
constexpr uint32_t sec_since_epoch () const
 
constexpr bool operator> (const time_point &t) const
 
constexpr bool operator>= (const time_point &t) const
 
constexpr bool operator< (const time_point &t) const
 
constexpr bool operator<= (const time_point &t) const
 
constexpr bool operator== (const time_point &t) const
 
constexpr bool operator!= (const time_point &t) const
 
constexpr time_pointoperator+= (const microseconds &m)
 
constexpr time_pointoperator-= (const microseconds &m)
 
constexpr time_point operator+ (const microseconds &m) const
 
constexpr time_point operator- (const microseconds &m) const
 
constexpr microseconds operator- (const time_point &m) const
 

Static Public Member Functions

static time_point now ()
 
static constexpr time_point maximum ()
 
static constexpr time_point min ()
 
static time_point from_iso_string (const fc::string &s)
 

Detailed Description

Definition at line 42 of file time.hpp.

Constructor & Destructor Documentation

◆ time_point()

fc::time_point::time_point ( microseconds e = microseconds())
inlineexplicitconstexpr

Definition at line 44 of file time.hpp.

44:elapsed(e){}
Here is the caller graph for this function:

Member Function Documentation

◆ from_iso_string()

time_point fc::time_point::from_iso_string ( const fc::string & s)
static

Definition at line 67 of file time.cpp.

68 { try {
69 auto dot = s.find( '.' );
70 if( dot == std::string::npos )
72 else {
73 auto ms = s.substr( dot );
74 ms[0] = '1';
75 while( ms.size() < 4 ) ms.push_back('0');
77 }
78 } FC_RETHROW_EXCEPTIONS( warn, "unable to convert ISO-formatted string to fc::time_point" ) }
static time_point_sec from_iso_string(const fc::string &s)
Definition time.cpp:39
constexpr time_point(microseconds e=microseconds())
Definition time.hpp:44
#define FC_RETHROW_EXCEPTIONS(LOG_LEVEL, FORMAT,...)
Catchs all exception's, std::exceptions, and ... and rethrows them after appending the provided log m...
constexpr microseconds milliseconds(int64_t s)
Definition time.hpp:33
int64_t to_int64(const fc::string &)
Definition string.cpp:92
char * s
Here is the call graph for this function:
Here is the caller graph for this function:

◆ maximum()

static constexpr time_point fc::time_point::maximum ( )
inlinestaticconstexpr

Definition at line 46 of file time.hpp.

46{ return time_point( microseconds::maximum() ); }
static constexpr microseconds maximum()
Definition time.hpp:14
Here is the call graph for this function:
Here is the caller graph for this function:

◆ min()

static constexpr time_point fc::time_point::min ( )
inlinestaticconstexpr

Definition at line 47 of file time.hpp.

47{ return time_point(); }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ now()

time_point fc::time_point::now ( )
static

Definition at line 14 of file time.cpp.

15 {
18 }
19 return time_point( microseconds( bch::duration_cast<bch::microseconds>( bch::system_clock::now().time_since_epoch() ).count() ) );
20 }
static fc::time_point fc_now()
Definition mock_time.cpp:29
static bool is_set()
Definition mock_time.hpp:23
constexpr const microseconds & time_since_epoch() const
Definition time.hpp:52
#define UNLIKELY(x)
int * count
Here is the call graph for this function:

◆ operator fc::string()

fc::time_point::operator fc::string ( ) const

Definition at line 50 of file time.cpp.

51 {
52 auto count = elapsed.count();
53 if (count >= 0) {
54 uint64_t secs = (uint64_t)count / 1000000ULL;
55 uint64_t msec = ((uint64_t)count % 1000000ULL) / 1000ULL;
56 string padded_ms = to_string((uint64_t)(msec + 1000ULL)).substr(1);
57 const auto ptime = boost::posix_time::from_time_t(time_t(secs));
58 return boost::posix_time::to_iso_extended_string(ptime) + "." + padded_ms;
59 } else {
60 // negative time_points serialized as "durations" in the ISO form with boost
61 // this is not very human readable but fits the precedent set by the above
62 auto as_duration = boost::posix_time::microseconds(count);
63 return boost::posix_time::to_iso_string(as_duration);
64 }
65 }
constexpr int64_t count() const
Definition time.hpp:26
fc::string to_string(double)
Definition string.cpp:131
unsigned __int64 uint64_t
Definition stdint.h:136
Here is the call graph for this function:

◆ operator!=()

bool fc::time_point::operator!= ( const time_point & t) const
inlineconstexpr

Definition at line 59 of file time.hpp.

59{ return elapsed._count !=t.elapsed._count; }

◆ operator+()

time_point fc::time_point::operator+ ( const microseconds & m) const
inlineconstexpr

Definition at line 62 of file time.hpp.

62{ return time_point(elapsed+m); }
Here is the call graph for this function:

◆ operator+=()

time_point & fc::time_point::operator+= ( const microseconds & m)
inlineconstexpr

Definition at line 60 of file time.hpp.

60{ elapsed+=m; return *this; }

◆ operator-() [1/2]

time_point fc::time_point::operator- ( const microseconds & m) const
inlineconstexpr

Definition at line 63 of file time.hpp.

63{ return time_point(elapsed-m); }
Here is the call graph for this function:

◆ operator-() [2/2]

microseconds fc::time_point::operator- ( const time_point & m) const
inlineconstexpr

Definition at line 64 of file time.hpp.

64{ return microseconds(elapsed.count() - m.elapsed.count()); }
Here is the call graph for this function:

◆ operator-=()

time_point & fc::time_point::operator-= ( const microseconds & m)
inlineconstexpr

Definition at line 61 of file time.hpp.

61{ elapsed-=m; return *this; }

◆ operator<()

bool fc::time_point::operator< ( const time_point & t) const
inlineconstexpr

Definition at line 56 of file time.hpp.

56{ return elapsed._count < t.elapsed._count; }

◆ operator<=()

bool fc::time_point::operator<= ( const time_point & t) const
inlineconstexpr

Definition at line 57 of file time.hpp.

57{ return elapsed._count <=t.elapsed._count; }

◆ operator==()

bool fc::time_point::operator== ( const time_point & t) const
inlineconstexpr

Definition at line 58 of file time.hpp.

58{ return elapsed._count ==t.elapsed._count; }

◆ operator>()

bool fc::time_point::operator> ( const time_point & t) const
inlineconstexpr

Definition at line 54 of file time.hpp.

54{ return elapsed._count > t.elapsed._count; }

◆ operator>=()

bool fc::time_point::operator>= ( const time_point & t) const
inlineconstexpr

Definition at line 55 of file time.hpp.

55{ return elapsed._count >=t.elapsed._count; }

◆ sec_since_epoch()

uint32_t fc::time_point::sec_since_epoch ( ) const
inlineconstexpr

Definition at line 53 of file time.hpp.

53{ return elapsed.count() / 1000000; }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ time_since_epoch()

const microseconds & fc::time_point::time_since_epoch ( ) const
inlineconstexpr

Definition at line 52 of file time.hpp.

52{ return elapsed; }
Here is the caller graph for this function:

The documentation for this class was generated from the following files: