CppCommon
1.0.4.1
C++ Common Library
|
#include <timestamp.h>
Public Member Functions | |
Timestamp () noexcept | |
Initialize timestamp with an epoch time. More... | |
Timestamp (uint64_t timestamp) noexcept | |
Initialize timestamp with a given time moment in nanoseconds. More... | |
template<class Clock , class Duration > | |
Timestamp (const std::chrono::time_point< Clock, Duration > &time_point) noexcept | |
Initialize timestamp with a given std::chrono time point. More... | |
Timestamp (const Timestamp &) noexcept=default | |
Timestamp (Timestamp &&) noexcept=default | |
~Timestamp () noexcept=default | |
Timestamp & | operator= (uint64_t timestamp) noexcept |
Timestamp & | operator= (const Timestamp &) noexcept=default |
Timestamp & | operator= (Timestamp &&) noexcept=default |
Timestamp & | operator+= (int64_t offset) noexcept |
Timestamp & | operator+= (const Timespan &offset) noexcept |
Timestamp & | operator-= (int64_t offset) noexcept |
Timestamp & | operator-= (const Timespan &offset) noexcept |
std::chrono::system_clock::time_point | chrono () const noexcept |
Convert timestamp to the std::chrono time point. More... | |
uint64_t | days () const noexcept |
Get total days of the current timestamp. More... | |
uint64_t | hours () const noexcept |
Get total hours of the current timestamp. More... | |
uint64_t | minutes () const noexcept |
Get total minutes of the current timestamp. More... | |
uint64_t | seconds () const noexcept |
Get total seconds of the current timestamp. More... | |
uint64_t | milliseconds () const noexcept |
Get total milliseconds of the current timestamp. More... | |
uint64_t | microseconds () const noexcept |
Get total microseconds of the current timestamp. More... | |
uint64_t | nanoseconds () const noexcept |
Get total nanoseconds of the current timestamp. More... | |
uint64_t | total () const noexcept |
Get total value of the current timestamp (total nanoseconds) More... | |
void | swap (Timestamp ×tamp) noexcept |
Swap two instances. More... | |
Static Public Member Functions | |
static Timestamp | days (int64_t days) noexcept |
Create the timestamp based on the given days value. More... | |
static Timestamp | hours (int64_t hours) noexcept |
Create the timestamp based on the given hours value. More... | |
static Timestamp | minutes (int64_t minutes) noexcept |
Create the timestamp based on the given minutes value. More... | |
static Timestamp | seconds (int64_t seconds) noexcept |
Create the timestamp based on the given seconds value. More... | |
static Timestamp | milliseconds (int64_t milliseconds) noexcept |
Create the timestamp based on the given milliseconds value. More... | |
static Timestamp | microseconds (int64_t microseconds) noexcept |
Create the timestamp based on the given microseconds value. More... | |
static Timestamp | nanoseconds (int64_t nanoseconds) noexcept |
Create the timestamp based on the given nanoseconds value. More... | |
static uint64_t | epoch () noexcept |
Get the epoch timestamp. More... | |
static uint64_t | utc () |
Get the UTC timestamp. More... | |
static uint64_t | local () |
Get the local timestamp. More... | |
static uint64_t | nano () |
Get the high resolution timestamp. More... | |
static uint64_t | rdts () |
Get the current value of RDTS (Read Time Stamp Counter) More... | |
Protected Attributes | |
uint64_t | _timestamp |
Timestamp value. More... | |
Friends | |
Timestamp | operator+ (const Timestamp ×tamp, int64_t offset) noexcept |
Timestamp | operator+ (int64_t offset, const Timestamp ×tamp) noexcept |
Timestamp | operator+ (const Timestamp ×tamp, const Timespan &offset) noexcept |
Timestamp | operator+ (const Timespan &offset, const Timestamp ×tamp) noexcept |
Timestamp | operator- (const Timestamp ×tamp, int64_t offset) noexcept |
Timestamp | operator- (int64_t offset, const Timestamp ×tamp) noexcept |
Timestamp | operator- (const Timestamp ×tamp, const Timespan &offset) noexcept |
Timestamp | operator- (const Timespan &offset, const Timestamp ×tamp) noexcept |
Timespan | operator- (const Timestamp ×tamp1, const Timestamp ×tamp2) noexcept |
bool | operator== (const Timestamp ×tamp1, uint64_t timestamp2) noexcept |
bool | operator== (uint64_t timestamp1, const Timestamp ×tamp2) noexcept |
bool | operator== (const Timestamp ×tamp1, const Timestamp ×tamp2) noexcept |
bool | operator!= (const Timestamp ×tamp1, uint64_t timestamp2) noexcept |
bool | operator!= (uint64_t timestamp1, const Timestamp ×tamp2) noexcept |
bool | operator!= (const Timestamp ×tamp1, const Timestamp ×tamp2) noexcept |
bool | operator> (const Timestamp ×tamp1, uint64_t timestamp2) noexcept |
bool | operator> (uint64_t timestamp1, const Timestamp ×tamp2) noexcept |
bool | operator> (const Timestamp ×tamp1, const Timestamp ×tamp2) noexcept |
bool | operator< (const Timestamp ×tamp1, uint64_t timestamp2) noexcept |
bool | operator< (uint64_t timestamp1, const Timestamp ×tamp2) noexcept |
bool | operator< (const Timestamp ×tamp1, const Timestamp ×tamp2) noexcept |
bool | operator>= (const Timestamp ×tamp1, uint64_t timestamp2) noexcept |
bool | operator>= (uint64_t timestamp1, const Timestamp ×tamp2) noexcept |
bool | operator>= (const Timestamp ×tamp1, const Timestamp ×tamp2) noexcept |
bool | operator<= (const Timestamp ×tamp1, uint64_t timestamp2) noexcept |
bool | operator<= (uint64_t timestamp1, const Timestamp ×tamp2) noexcept |
bool | operator<= (const Timestamp ×tamp1, const Timestamp ×tamp2) noexcept |
void | swap (Timestamp ×tamp1, Timestamp ×tamp2) noexcept |
Timestamp wraps time moment in nanoseconds and allows to get separate values of days, hours, minutes, seconds, milliseconds, microseconds or nanoseconds. Also it is possible to get difference between two timestamps as a timespan.
Nanosecond timestamp based on 64-bit integer can represent each nanosecond in the time range of ~584.554531 years. Therefore timestamp bounds from 01.01.1970 to 31.12.2553.
Timestamp epoch January 1, 1970 at 00:00:00
Not thread-safe.
Definition at line 29 of file timestamp.h.
|
inlinenoexcept |
Initialize timestamp with an epoch time.
Definition at line 33 of file timestamp.h.
|
inlineexplicitnoexcept |
Initialize timestamp with a given time moment in nanoseconds.
timestamp | - Time moment in nanoseconds |
Definition at line 38 of file timestamp.h.
|
inlineexplicitnoexcept |
Initialize timestamp with a given std::chrono time point.
time_point | - std::chrono time point |
Definition at line 44 of file timestamp.h.
|
defaultnoexcept |
|
defaultnoexcept |
|
defaultnoexcept |
|
inlinenoexcept |
Convert timestamp to the std::chrono time point.
Definition at line 130 of file timestamp.h.
|
inlinenoexcept |
Get total days of the current timestamp.
Definition at line 134 of file timestamp.h.
|
inlinestaticnoexcept |
Create the timestamp based on the given days value.
Definition at line 159 of file timestamp.h.
|
inlinestaticnoexcept |
Get the epoch timestamp.
Thread-safe.
Definition at line 186 of file timestamp.h.
|
inlinenoexcept |
Get total hours of the current timestamp.
Definition at line 137 of file timestamp.h.
|
inlinestaticnoexcept |
Create the timestamp based on the given hours value.
Definition at line 162 of file timestamp.h.
|
static |
Get the local timestamp.
Thread-safe.
Definition at line 123 of file timestamp.cpp.
|
inlinenoexcept |
Get total microseconds of the current timestamp.
Definition at line 149 of file timestamp.h.
|
inlinestaticnoexcept |
Create the timestamp based on the given microseconds value.
Definition at line 174 of file timestamp.h.
|
inlinenoexcept |
Get total milliseconds of the current timestamp.
Definition at line 146 of file timestamp.h.
|
inlinestaticnoexcept |
Create the timestamp based on the given milliseconds value.
Definition at line 171 of file timestamp.h.
|
inlinenoexcept |
Get total minutes of the current timestamp.
Definition at line 140 of file timestamp.h.
|
inlinestaticnoexcept |
Create the timestamp based on the given minutes value.
Definition at line 165 of file timestamp.h.
|
static |
Get the high resolution timestamp.
Thread-safe.
Definition at line 153 of file timestamp.cpp.
|
inlinenoexcept |
Get total nanoseconds of the current timestamp.
Definition at line 152 of file timestamp.h.
|
inlinestaticnoexcept |
Create the timestamp based on the given nanoseconds value.
Definition at line 177 of file timestamp.h.
Definition at line 57 of file timestamp.h.
|
inlinenoexcept |
Definition at line 55 of file timestamp.h.
Definition at line 62 of file timestamp.h.
|
inlinenoexcept |
Definition at line 60 of file timestamp.h.
|
inlinenoexcept |
Definition at line 49 of file timestamp.h.
|
static |
Get the current value of RDTS (Read Time Stamp Counter)
Counts the number of CPU cycles since reset. The Time Stamp Counter (TSC) is a 64-bit register present on all x86 processors since the Pentium.
Thread-safe.
https://en.wikipedia.org/wiki/Time_Stamp_Counter
Definition at line 205 of file timestamp.cpp.
|
inlinenoexcept |
Get total seconds of the current timestamp.
Definition at line 143 of file timestamp.h.
|
inlinestaticnoexcept |
Create the timestamp based on the given seconds value.
Definition at line 168 of file timestamp.h.
|
inlinenoexcept |
Swap two instances.
Definition at line 11 of file timestamp.inl.
|
inlinenoexcept |
Get total value of the current timestamp (total nanoseconds)
Definition at line 156 of file timestamp.h.
|
static |
Get the UTC timestamp.
Thread-safe.
Definition at line 105 of file timestamp.cpp.
Definition at line 98 of file timestamp.h.
|
friend |
Definition at line 94 of file timestamp.h.
|
friend |
Definition at line 96 of file timestamp.h.
Definition at line 71 of file timestamp.h.
Definition at line 69 of file timestamp.h.
Definition at line 65 of file timestamp.h.
Definition at line 67 of file timestamp.h.
Definition at line 80 of file timestamp.h.
Definition at line 78 of file timestamp.h.
Definition at line 74 of file timestamp.h.
Definition at line 83 of file timestamp.h.
Definition at line 76 of file timestamp.h.
Definition at line 112 of file timestamp.h.
|
friend |
Definition at line 108 of file timestamp.h.
|
friend |
Definition at line 110 of file timestamp.h.
Definition at line 126 of file timestamp.h.
|
friend |
Definition at line 122 of file timestamp.h.
|
friend |
Definition at line 124 of file timestamp.h.
Definition at line 91 of file timestamp.h.
|
friend |
Definition at line 87 of file timestamp.h.
|
friend |
Definition at line 89 of file timestamp.h.
Definition at line 105 of file timestamp.h.
|
friend |
Definition at line 101 of file timestamp.h.
|
friend |
Definition at line 103 of file timestamp.h.
Definition at line 119 of file timestamp.h.
|
friend |
Definition at line 115 of file timestamp.h.
|
friend |
Definition at line 117 of file timestamp.h.
Definition at line 17 of file timestamp.inl.
|
protected |
Timestamp value.
Definition at line 231 of file timestamp.h.