#include <icy/datetime.h>A Timestamp stores a monotonic* time value with (theoretical) microseconds resolution. Timestamps can be compared with each other and simple arithmetics are supported.
[*] Note that Timestamp values are only monotonic as long as the systems's clock is monotonic as well (and not, e.g. set back).
Timestamps are UTC (Coordinated Universal Time) based and thus independent of the timezone in effect on the system.
| Return | Name | Description |
|---|---|---|
Timestamp | Creates a timestamp with the current time. | |
Timestamp | Creates a timestamp from the given time value. | |
Timestamp | Copy constructor. | |
~Timestamp | Destroys the timestamp. | |
void | swap | Swaps the Timestamp with another one. |
void | update | Updates the Timestamp with the current time. |
bool | operator== const inline | |
bool | operator!= const inline | |
bool | operator> const inline | |
bool | operator>= const inline | |
bool | operator< const inline | |
bool | operator<= const inline | |
Timestamp | operator+ const inline | |
Timestamp | operator- const inline | |
TimeDiff | operator- const inline | |
Timestamp & | operator+= inline | |
Timestamp & | operator-= inline | |
std::time_t | epochTime const inline | Returns the timestamp expressed in time_t. time_t base time is midnight, January 1, 1970. Resolution is one second. |
UtcTimeVal | utcTime const inline | Returns the timestamp expressed in UTC-based time. UTC base time is midnight, October 15, 1582. Resolution is 100 nanoseconds. |
TimeVal | epochMicroseconds const inline | Returns the timestamp expressed in microseconds since the Unix epoch, midnight, January 1, 1970. |
TimeDiff | elapsed const inline | Returns the time elapsed since the time denoted by the timestamp. Equivalent to Timestamp() - *this. |
bool | isElapsed const inline | Returns true iff the given interval has passed since the time denoted by the timestamp. |
Timestamp()Creates a timestamp with the current time.
Timestamp(TimeVal tv)Creates a timestamp from the given time value.
Timestamp(const Timestamp & other)Copy constructor.
~Timestamp()Destroys the timestamp.
void swap(Timestamp & timestamp)Swaps the Timestamp with another one.
void update()Updates the Timestamp with the current time.
const inline
inline bool operator==(const Timestamp & ts) constconst inline
inline bool operator!=(const Timestamp & ts) constconst inline
inline bool operator>(const Timestamp & ts) constconst inline
inline bool operator>=(const Timestamp & ts) constconst inline
inline bool operator<(const Timestamp & ts) constconst inline
inline bool operator<=(const Timestamp & ts) constconst inline
inline Timestamp operator+(TimeDiff d) constconst inline
inline Timestamp operator-(TimeDiff d) constconst inline
inline TimeDiff operator-(const Timestamp & ts) constinline
inline Timestamp & operator+=(TimeDiff d)inline
inline Timestamp & operator-=(TimeDiff d)const inline
inline std::time_t epochTime() constReturns the timestamp expressed in time_t. time_t base time is midnight, January 1, 1970. Resolution is one second.
const inline
inline UtcTimeVal utcTime() constReturns the timestamp expressed in UTC-based time. UTC base time is midnight, October 15, 1582. Resolution is 100 nanoseconds.
const inline
inline TimeVal epochMicroseconds() constReturns the timestamp expressed in microseconds since the Unix epoch, midnight, January 1, 1970.
const inline
inline TimeDiff elapsed() constReturns the time elapsed since the time denoted by the timestamp. Equivalent to Timestamp() - *this.
const inline
inline bool isElapsed(TimeDiff interval) constReturns true iff the given interval has passed since the time denoted by the timestamp.
| Return | Name | Description |
|---|---|---|
Timestamp | fromEpochTime static | Creates a timestamp from a std::time_t. |
Timestamp | fromUtcTime static | Creates a timestamp from a UTC time value. |
TimeVal | resolution static inline | Returns the resolution in units per second. Since the timestamp has microsecond resolution, the returned value is always 1000000. |
static
static Timestamp fromEpochTime(std::time_t t)Creates a timestamp from a std::time_t.
static
static Timestamp fromUtcTime(UtcTimeVal val)Creates a timestamp from a UTC time value.
static inline
static inline TimeVal resolution()Returns the resolution in units per second. Since the timestamp has microsecond resolution, the returned value is always 1000000.
| Name | Description |
|---|---|
TimeVal | monotonic UTC time value in microsecond resolution |
UtcTimeVal | monotonic UTC time value in 100 nanosecond resolution |
TimeDiff | difference between two timestamps in microseconds |
std::int64_t TimeVal()monotonic UTC time value in microsecond resolution
std::int64_t UtcTimeVal()monotonic UTC time value in 100 nanosecond resolution
std::int64_t TimeDiff()difference between two timestamps in microseconds
| Return | Name | Description |
|---|---|---|
TimeVal | _ts |
TimeVal _ts