Home
Base module

Timestamp

A Timestamp stores a monotonic* time value with (theoretical) microseconds resolution.

Timestamp

#include <icy/datetime.h>
class Timestamp

Defined 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

NameKindOwner
TimestampfunctionDeclared here
TimestampfunctionDeclared here
TimestampfunctionDeclared here
~TimestampfunctionDeclared here
operator=functionDeclared here
operator=functionDeclared here
swapfunctionDeclared here
updatefunctionDeclared here
operator==functionDeclared here
operator!=functionDeclared here
operator>functionDeclared here
operator>=functionDeclared here
operator<functionDeclared here
operator<=functionDeclared here
operator+functionDeclared here
operator-functionDeclared here
operator-functionDeclared here
operator+=functionDeclared here
operator-=functionDeclared here
epochTimefunctionDeclared here
utcTimefunctionDeclared here
epochMicrosecondsfunctionDeclared here
elapsedfunctionDeclared here
isElapsedfunctionDeclared here
fromEpochTimefunctionDeclared here
fromUtcTimefunctionDeclared here
resolutionfunctionDeclared here
TimeValtypedefDeclared here
UtcTimeValtypedefDeclared here
TimeDifftypedefDeclared here
_tsvariableDeclared here

Public Methods

ReturnNameDescription
TimestampCreates a timestamp with the current time.
TimestampCreates a timestamp from the given time value.
TimestampCopy constructor.
~TimestampDestroys the timestamp.
voidswapSwaps the Timestamp with another one.
voidupdateUpdates the Timestamp with the current time.
booloperator== const inline
booloperator!= const inline
booloperator> const inline
booloperator>= const inline
booloperator< const inline
booloperator<= const inline
Timestampoperator+ const inline
Timestampoperator- const inline
TimeDiffoperator- const inline
Timestamp &operator+= inline
Timestamp &operator-= inline
std::time_tepochTime const inlineReturns the timestamp expressed in time_t. time_t base time is midnight, January 1, 1970. Resolution is one second.
UtcTimeValutcTime const inlineReturns the timestamp expressed in UTC-based time. UTC base time is midnight, October 15, 1582. Resolution is 100 nanoseconds.
TimeValepochMicroseconds const inlineReturns the timestamp expressed in microseconds since the Unix epoch, midnight, January 1, 1970.
TimeDiffelapsed const inlineReturns the time elapsed since the time denoted by the timestamp. Equivalent to Timestamp() - *this.
boolisElapsed const inlineReturns 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) const

Defined in src/base/include/icy/datetime.h:64


operator!=

const inline

inline bool operator!=(const Timestamp & ts) const

Defined in src/base/include/icy/datetime.h:65


operator>

const inline

inline bool operator>(const Timestamp & ts) const

Defined in src/base/include/icy/datetime.h:66


operator>=

const inline

inline bool operator>=(const Timestamp & ts) const

Defined in src/base/include/icy/datetime.h:67


operator<

const inline

inline bool operator<(const Timestamp & ts) const

Defined in src/base/include/icy/datetime.h:68


operator<=

const inline

inline bool operator<=(const Timestamp & ts) const

Defined in src/base/include/icy/datetime.h:69


operator+

const inline

inline Timestamp operator+(TimeDiff d) const

Defined in src/base/include/icy/datetime.h:71


operator-

const inline

inline Timestamp operator-(TimeDiff d) const

Defined in src/base/include/icy/datetime.h:72


operator-

const inline

inline TimeDiff operator-(const Timestamp & ts) const

Defined 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() const

Defined 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() const

Defined 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() const

Defined 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() const

Defined 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) const

Defined 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

ReturnNameDescription
TimestampfromEpochTime staticCreates a timestamp from a std::time_t.
TimestampfromUtcTime staticCreates a timestamp from a UTC time value.
TimeValresolution static inlineReturns 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

NameDescription
TimeValmonotonic UTC time value in microsecond resolution
UtcTimeValmonotonic UTC time value in 100 nanosecond resolution
TimeDiffdifference between two timestamps in microseconds

TimeVal

using TimeVal = std::int64_t

Defined in src/base/include/icy/datetime.h:39

monotonic UTC time value in microsecond resolution


UtcTimeVal

using UtcTimeVal = std::int64_t

Defined in src/base/include/icy/datetime.h:40

monotonic UTC time value in 100 nanosecond resolution


TimeDiff

using TimeDiff = std::int64_t

Defined in src/base/include/icy/datetime.h:41

difference between two timestamps in microseconds

Private Attributes

ReturnNameDescription
TimeVal_ts

_ts

TimeVal _ts

Defined in src/base/include/icy/datetime.h:111