CatapultServer
v0.5.0.1 (Elephant)
|
Go to the documentation of this file.
27 namespace catapult {
namespace utils {
32 template<
typename TRep,
typename TPeriod>
33 constexpr
explicit TimeSpan(
const std::chrono::duration<TRep, TPeriod>& duration)
34 :
m_millis(std::chrono::duration_cast<std::chrono::milliseconds>(duration))
60 return TimeSpan(std::chrono::milliseconds(milliseconds));
69 template<
typename TDuration>
71 return static_cast<uint64_t>(std::chrono::duration_cast<TDuration>(
millis).count());
76 constexpr uint64_t
hours()
const {
77 return ConvertToDuration<std::chrono::hours>(
m_millis);
82 return ConvertToDuration<std::chrono::minutes>(
m_millis);
87 return ConvertToDuration<std::chrono::seconds>(
m_millis);
92 return static_cast<uint64_t>(
m_millis.count());
103 return !(*
this == rhs);
constexpr Timestamp SubtractNonNegative(const Timestamp ×tamp, const TimeSpan &timeSpan)
Subtracts timeSpan from timestamp and returns the maximum of the difference and zero.
Definition: TimeSpan.h:139
std::chrono::milliseconds m_millis
Definition: TimeSpan.h:127
constexpr bool operator==(const TimeSpan &rhs) const
Returns true if this time span is equal to rhs.
Definition: TimeSpan.h:97
constexpr bool operator>=(const TimeSpan &rhs) const
Returns true if this time span is greater than or equal to rhs.
Definition: TimeSpan.h:107
static constexpr TimeSpan FromDifference(Timestamp end, Timestamp start)
Creates a time span from the difference between start and end.
Definition: TimeSpan.h:64
static constexpr TimeSpan FromMilliseconds(uint64_t milliseconds)
Creates a time span from the given number of milliseconds.
Definition: TimeSpan.h:59
Represents a time duration.
Definition: TimeSpan.h:30
constexpr ValueType unwrap() const
Unwraps this value and returns the underlying raw value.
Definition: BaseValue.h:53
constexpr Timestamp operator+(const Timestamp ×tamp, const TimeSpan &timeSpan)
Adds timestamp and a timeSpan resulting in new timestamp.
Definition: TimeSpan.h:134
static constexpr TimeSpan FromSeconds(uint64_t seconds)
Creates a time span from the given number of seconds.
Definition: TimeSpan.h:54
static constexpr uint64_t ConvertToDuration(const std::chrono::milliseconds &millis)
Definition: TimeSpan.h:70
constexpr uint64_t seconds() const
Returns the number of seconds.
Definition: TimeSpan.h:86
constexpr TimeSpan(const std::chrono::duration< TRep, TPeriod > &duration)
Definition: TimeSpan.h:33
constexpr uint64_t hours() const
Returns the number of hours.
Definition: TimeSpan.h:76
static constexpr TimeSpan FromHours(uint64_t hours)
Creates a time span from the given number of hours.
Definition: TimeSpan.h:44
constexpr bool operator!=(const TimeSpan &rhs) const
Returns true if this time span is not equal to rhs.
Definition: TimeSpan.h:102
constexpr TimeSpan()
Creates a default (zero) time span.
Definition: TimeSpan.h:39
static constexpr TimeSpan FromMinutes(uint64_t minutes)
Creates a time span from the given number of minutes.
Definition: TimeSpan.h:49
std::ostream & operator<<(std::ostream &out, const BlockSpan &blockSpan)
Insertion operator for outputting blockSpan to out.
Definition: BlockSpan.cpp:27
constexpr bool operator<=(const TimeSpan &rhs) const
Returns true if this time span is less than or equal to rhs.
Definition: TimeSpan.h:117
constexpr uint64_t millis() const
Returns the number of milliseconds.
Definition: TimeSpan.h:91
constexpr uint64_t minutes() const
Returns the number of minutes.
Definition: TimeSpan.h:81
constexpr bool operator>(const TimeSpan &rhs) const
Returns true if this time span is greater than rhs.
Definition: TimeSpan.h:112
utils::BaseValue< uint64_t, Timestamp_tag > Timestamp
Definition: src/catapult/types.h:73
Definition: AddressExtractionExtension.cpp:28
constexpr bool operator<(const TimeSpan &rhs) const
Returns true if this time span is less than rhs.
Definition: TimeSpan.h:122