qb
2.0.0.0
C++17 Actor Framework
|
Represents a point in time with nanosecond precision. More...
#include <timestamp.h>
Public Types | |
using | rep = uint64_t |
Type used for nanosecond representation. | |
using | chrono_time_point |
Underlying std::chrono time point type. |
Public Member Functions | |
constexpr | TimePoint () noexcept=default |
Default constructor, initializes to epoch. | |
constexpr | TimePoint (rep nanoseconds) noexcept |
Constructs a time point with specified time since epoch. | |
template<typename Clock, typename ChronoDuration> | |
TimePoint (const std::chrono::time_point< Clock, ChronoDuration > &time_point) noexcept | |
Constructs a time point from std::chrono::time_point. | |
constexpr | TimePoint (const TimePoint &) noexcept=default |
constexpr | TimePoint (TimePoint &&) noexcept=default |
constexpr TimePoint & | operator= (const TimePoint &) noexcept=default |
constexpr TimePoint & | operator= (TimePoint &&) noexcept=default |
chrono_time_point | to_chrono () const noexcept |
Converts to std::chrono::time_point. | |
template<typename Clock, typename ChronoDuration = typename Clock::duration> | |
std::chrono::time_point< Clock, ChronoDuration > | to () const noexcept |
Converts to any std::chrono::time_point. | |
constexpr rep | days () const noexcept |
Gets the time in days since epoch. | |
constexpr double | days_float () const noexcept |
Gets the time in days since epoch with fractional precision. | |
constexpr rep | hours () const noexcept |
Gets the time in hours since epoch. | |
constexpr double | hours_float () const noexcept |
Gets the time in hours since epoch with fractional precision. | |
constexpr rep | minutes () const noexcept |
Gets the time in minutes since epoch. | |
constexpr double | minutes_float () const noexcept |
Gets the time in minutes since epoch with fractional precision. | |
constexpr rep | seconds () const noexcept |
Gets the time in seconds since epoch. | |
constexpr double | seconds_float () const noexcept |
Gets the time in seconds since epoch with fractional precision. | |
constexpr rep | milliseconds () const noexcept |
Gets the time in milliseconds since epoch. | |
constexpr double | milliseconds_float () const noexcept |
Gets the time in milliseconds since epoch with fractional precision. | |
constexpr rep | microseconds () const noexcept |
Gets the time in microseconds since epoch. | |
constexpr double | microseconds_float () const noexcept |
Gets the time in microseconds since epoch with fractional precision. | |
constexpr rep | nanoseconds () const noexcept |
Gets the time in nanoseconds since epoch. | |
constexpr double | nanoseconds_float () const noexcept |
Gets the time in nanoseconds since epoch with double precision. | |
Duration | time_since_epoch () const noexcept |
Gets the duration since epoch. | |
constexpr rep | count () const noexcept |
Gets the total time in nanoseconds since epoch. | |
std::string | format (std::string_view format) const |
Formats the time point as a string. | |
std::string | to_iso8601 () const |
Converts to ISO8601 string. | |
TimePoint & | operator+= (const Duration &duration) noexcept |
Adds a duration to this time point. | |
TimePoint & | operator-= (const Duration &duration) noexcept |
Subtracts a duration from this time point. |
Static Public Member Functions | |
static constexpr TimePoint | epoch () noexcept |
Represents the epoch (1970-01-01 00:00:00 UTC) | |
static TimePoint | now () noexcept |
Gets current system time. | |
static constexpr TimePoint | from_days (int64_t days) noexcept |
Factory method to create a TimePoint from days since epoch. | |
static constexpr TimePoint | from_hours (int64_t hours) noexcept |
Factory method to create a TimePoint from hours since epoch. | |
static constexpr TimePoint | from_minutes (int64_t minutes) noexcept |
Factory method to create a TimePoint from minutes since epoch. | |
static constexpr TimePoint | from_seconds (int64_t seconds) noexcept |
Factory method to create a TimePoint from seconds since epoch. | |
static constexpr TimePoint | from_milliseconds (int64_t ms) noexcept |
Factory method to create a TimePoint from milliseconds since epoch. | |
static constexpr TimePoint | from_microseconds (int64_t us) noexcept |
Factory method to create a TimePoint from microseconds since epoch. | |
static constexpr TimePoint | from_nanoseconds (int64_t ns) noexcept |
Factory method to create a TimePoint from nanoseconds since epoch. | |
static std::optional< TimePoint > | from_iso8601 (std::string_view iso8601) noexcept |
Creates a TimePoint from ISO8601 string. | |
static std::optional< TimePoint > | parse (std::string_view time_string, std::string_view format) noexcept |
Factory method to parse a string into a TimePoint. | |
static uint64_t | read_tsc () noexcept |
Reads CPU timestamp counter. | |
static uint64_t | nano () noexcept |
Gets the current time in nanoseconds since epoch. |
Protected Attributes | |
rep | _time_since_epoch {0} |
Time in nanoseconds since epoch. |
Represents a point in time with nanosecond precision.
TimePoint provides a platform-independent way to represent moments in time with high precision. It supports arithmetic operations with Duration objects and provides conversions to various time units and formats.
Underlying std::chrono time point type.
|
inlineexplicitconstexprnoexcept |
Constructs a time point with specified time since epoch.
nanoseconds | Time in nanoseconds since epoch |
|
inlineexplicitnoexcept |
Constructs a time point from std::chrono::time_point.
Clock | The clock type |
Duration | The duration type |
time_point | A std::chrono time point |
|
inlinestaticnoexcept |
Gets current system time.
|
inlinenodiscardnoexcept |
Converts to std::chrono::time_point.
|
inlinenodiscardnoexcept |
Converts to any std::chrono::time_point.
Clock | The target clock type |
Duration | The target duration type |
|
inlinestaticnodiscardconstexprnoexcept |
|
inlinestaticnodiscardconstexprnoexcept |
|
inlinestaticnodiscardconstexprnoexcept |
|
inlinestaticnodiscardconstexprnoexcept |
|
inlinestaticnodiscardconstexprnoexcept |
|
inlinestaticnodiscardconstexprnoexcept |
|
inlinestaticnodiscardconstexprnoexcept |
|
inlinestaticnodiscardnoexcept |
|
inlinestaticnodiscardnoexcept |
|
inlinenodiscardconstexprnoexcept |
Gets the time in days since epoch.
|
inlinenodiscardconstexprnoexcept |
Gets the time in days since epoch with fractional precision.
|
inlinenodiscardconstexprnoexcept |
Gets the time in hours since epoch.
|
inlinenodiscardconstexprnoexcept |
Gets the time in hours since epoch with fractional precision.
|
inlinenodiscardconstexprnoexcept |
Gets the time in minutes since epoch.
|
inlinenodiscardconstexprnoexcept |
Gets the time in minutes since epoch with fractional precision.
|
inlinenodiscardconstexprnoexcept |
Gets the time in seconds since epoch.
|
inlinenodiscardconstexprnoexcept |
Gets the time in seconds since epoch with fractional precision.
|
inlinenodiscardconstexprnoexcept |
Gets the time in milliseconds since epoch.
|
inlinenodiscardconstexprnoexcept |
Gets the time in milliseconds since epoch with fractional precision.
|
inlinenodiscardconstexprnoexcept |
Gets the time in microseconds since epoch.
|
inlinenodiscardconstexprnoexcept |
Gets the time in microseconds since epoch with fractional precision.
|
inlinenodiscardconstexprnoexcept |
Gets the time in nanoseconds since epoch.
|
inlinenodiscardconstexprnoexcept |
Gets the time in nanoseconds since epoch with double precision.
|
inlinenodiscardnoexcept |
Gets the duration since epoch.
|
inlinenodiscardconstexprnoexcept |
Gets the total time in nanoseconds since epoch.
|
inlinenodiscard |
Formats the time point as a string.
format | Format string (strftime compatible) |
|
inlinenodiscard |
Converts to ISO8601 string.
|
inlinestaticnoexcept |
Reads CPU timestamp counter.
Adds a duration to this time point.
duration | Duration to add |
Subtracts a duration from this time point.
duration | Duration to subtract |
|
inlinestaticnoexcept |
Gets the current time in nanoseconds since epoch.