Timestamp
Timestamp
#include <icy/datetime.h>class TimestampDefined in src/base/include/icy/datetime.h:36
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.
List of all members
| Name | Kind | Owner |
|---|---|---|
Timestamp | function | Declared here |
Timestamp | function | Declared here |
Timestamp | function | Declared here |
~Timestamp | function | Declared here |
operator= | function | Declared here |
operator= | function | Declared here |
swap | function | Declared here |
update | function | Declared here |
operator== | function | Declared here |
operator!= | function | Declared here |
operator> | function | Declared here |
operator>= | function | Declared here |
operator< | function | Declared here |
operator<= | function | Declared here |
operator+ | function | Declared here |
operator- | function | Declared here |
operator- | function | Declared here |
operator+= | function | Declared here |
operator-= | function | Declared here |
epochTime | function | Declared here |
utcTime | function | Declared here |
epochMicroseconds | function | Declared here |
elapsed | function | Declared here |
isElapsed | function | Declared here |
fromEpochTime | function | Declared here |
fromUtcTime | function | Declared here |
resolution | function | Declared here |
TimeVal | typedef | Declared here |
UtcTimeVal | typedef | Declared here |
TimeDiff | typedef | Declared here |
_ts | variable | Declared here |
Public Methods
| 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
Timestamp()Defined in src/base/include/icy/datetime.h:44
Creates a timestamp with the current time.
Timestamp
Timestamp(TimeVal tv)Defined in src/base/include/icy/datetime.h:47
Creates a timestamp from the given time value.
Timestamp
Timestamp(const Timestamp & other)Defined in src/base/include/icy/datetime.h:50
Copy constructor.
~Timestamp
~Timestamp()Defined in src/base/include/icy/datetime.h:53
Destroys the timestamp.
swap
void swap(Timestamp & timestamp)Defined in src/base/include/icy/datetime.h:59
Swaps the Timestamp with another one.
update
void update()Defined in src/base/include/icy/datetime.h:62
Updates the Timestamp with the current time.
operator==
const inline
inline bool operator==(const Timestamp & ts) constDefined in src/base/include/icy/datetime.h:64
operator!=
const inline
inline bool operator!=(const Timestamp & ts) constDefined in src/base/include/icy/datetime.h:65
operator>
const inline
inline bool operator>(const Timestamp & ts) constDefined in src/base/include/icy/datetime.h:66
operator>=
const inline
inline bool operator>=(const Timestamp & ts) constDefined in src/base/include/icy/datetime.h:67
operator<
const inline
inline bool operator<(const Timestamp & ts) constDefined in src/base/include/icy/datetime.h:68
operator<=
const inline
inline bool operator<=(const Timestamp & ts) constDefined in src/base/include/icy/datetime.h:69
operator+
const inline
inline Timestamp operator+(TimeDiff d) constDefined in src/base/include/icy/datetime.h:71
operator-
const inline
inline Timestamp operator-(TimeDiff d) constDefined in src/base/include/icy/datetime.h:72
operator-
const inline
inline TimeDiff operator-(const Timestamp & ts) constDefined in src/base/include/icy/datetime.h:73
operator+=
inline
inline Timestamp & operator+=(TimeDiff d)Defined in src/base/include/icy/datetime.h:74
operator-=
inline
inline Timestamp & operator-=(TimeDiff d)Defined in src/base/include/icy/datetime.h:75
epochTime
const inline
inline std::time_t epochTime() constDefined in src/base/include/icy/datetime.h:80
Returns the timestamp expressed in time_t. time_t base time is midnight, January 1, 1970. Resolution is one second.
utcTime
const inline
inline UtcTimeVal utcTime() constDefined in src/base/include/icy/datetime.h:85
Returns the timestamp expressed in UTC-based time. UTC base time is midnight, October 15, 1582. Resolution is 100 nanoseconds.
epochMicroseconds
const inline
inline TimeVal epochMicroseconds() constDefined in src/base/include/icy/datetime.h:89
Returns the timestamp expressed in microseconds since the Unix epoch, midnight, January 1, 1970.
elapsed
const inline
inline TimeDiff elapsed() constDefined in src/base/include/icy/datetime.h:93
Returns the time elapsed since the time denoted by the timestamp. Equivalent to Timestamp() - *this.
isElapsed
const inline
inline bool isElapsed(TimeDiff interval) constDefined in src/base/include/icy/datetime.h:97
Returns true iff the given interval has passed since the time denoted by the timestamp.
Public Static Methods
| 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. |
fromEpochTime
static
static Timestamp fromEpochTime(std::time_t t)Defined in src/base/include/icy/datetime.h:100
Creates a timestamp from a std::time_t.
fromUtcTime
static
static Timestamp fromUtcTime(UtcTimeVal val)Defined in src/base/include/icy/datetime.h:103
Creates a timestamp from a UTC time value.
resolution
static inline
static inline TimeVal resolution()Defined in src/base/include/icy/datetime.h:108
Returns the resolution in units per second. Since the timestamp has microsecond resolution, the returned value is always 1000000.
Public Types
| 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 |
TimeVal
using TimeVal = std::int64_tDefined in src/base/include/icy/datetime.h:39
monotonic UTC time value in microsecond resolution
UtcTimeVal
using UtcTimeVal = std::int64_tDefined in src/base/include/icy/datetime.h:40
monotonic UTC time value in 100 nanosecond resolution
TimeDiff
using TimeDiff = std::int64_tDefined in src/base/include/icy/datetime.h:41
difference between two timestamps in microseconds
Private Attributes
| Return | Name | Description |
|---|---|---|
TimeVal | _ts |
_ts
TimeVal _ts