|
TEC
A lightweight C++ library enabling safe, efficient execution in multithreaded and concurrent systems.
|
A point in time. More...
#include <tec_timestamp.hpp>
Public Types | |
Type aliases | |
| using | count_t = int64_t |
| Underlying integer type used to store nanosecond count. | |
| using | duration_t = std::chrono::nanoseconds |
| Duration unit used by this timestamp (nanoseconds) | |
| using | system_clock_t = std::chrono::system_clock |
| Clock type used as the basis for time_point conversion. | |
| using | time_point_t = std::chrono::time_point< system_clock_t, duration_t > |
| std::chrono time_point type with nanosecond precision | |
Public Member Functions | |
| Timestamp () | |
| Default constructor — creates timestamp at epoch (count = 0) | |
| Timestamp (count_t _count) | |
| Construct from raw nanosecond count since epoch. | |
| Timestamp (duration_t d) | |
| Construct from std::chrono::nanoseconds duration. | |
| Timestamp (const Timestamp &)=default | |
| Timestamp (Timestamp &&)=default | |
| duration_t | dur () const |
| Returns the duration since epoch as std::chrono::nanoseconds. | |
| std::tm | utc_time () const |
| Returns broken-down UTC time as std::tm. | |
| std::tm | local_time () const |
| Returns broken-down local time as std::tm. | |
| std::string | utc_time_str () const |
| Returns ISO 8601 string in UTC (with Z suffix) | |
| std::string | local_time_str () const |
| Returns ISO 8601 string in local time (with timezone offset) | |
Static Public Member Functions | |
| static Timestamp | now () |
| Returns current time as Timestamp (UTC-based, nanosecond precision) | |
Public Attributes | |
| count_t | count |
| Nanoseconds since Unix epoch (1970-01-01T00:00:00Z). | |
A point in time.
Timestamp represents a point in time independent of any time zone or local calendar, encoded as a count of nanoseconds. The count is relative to an epoch at UTC midnight on January 1, 1970.
|
inline |
Returns the duration since epoch as std::chrono::nanoseconds.
|
inline |
Returns broken-down local time as std::tm.
Uses thread-safe wrapper around std::localtime
|
inline |
Returns ISO 8601 string in local time (with timezone offset)
Returns current time as Timestamp (UTC-based, nanosecond precision)
Uses std::chrono::system_clock::now() and converts to nanoseconds. This is the recommended way to obtain "current time" in this system.
|
inline |
Returns broken-down UTC time as std::tm.
Uses thread-safe wrapper around std::gmtime
|
inline |
Returns ISO 8601 string in UTC (with Z suffix)
| count_t tec::Timestamp::count |
Nanoseconds since Unix epoch (1970-01-01T00:00:00Z).
Represents the number of nanoseconds elapsed since 1970-01-01 00:00:00 UTC. The valid range is approximately 1970-01-01 to 2262-04-11 (due to 64-bit signed integer limits).
Negative values represent times before the Unix epoch.