Class Time

Class Documentation

class Time

Time represents a time value and can:

  • Be incremented by Duration expressed as seconds, nanoseconds, milliseconds, or Duration objects.

  • Be converted to and from Times expressed in milliseconds (or other units) as integer types.

Public Functions

Time()

Create a Time of zero seconds.

explicit Time(int64_t sec, uint32_t nanosec = 0)

Create a Time elapsing a specific amount of time.

int64_t sec() const
Returns

number of seconds

void sec(int64_t s)

Set number of seconds

Parameters

s – number of seconds

uint32_t nanosec() const
Returns

number of nanoseconds

void nanosec(uint32_t ns)

Set number of nanoseconds

Parameters

ns – number of nanoseconds

int compare(const Time &that) const

Returns an integer indicating the result of a comparison of two Times: 1 if this Time is greater than the comparator (that) -1 if the Time is less than the comparator (that) 0 if the Time matches the comparator (that)

Parameters

thatTime to compare

Returns

comparison result

bool operator>(const Time &that) const
Parameters

thatTime to compare

Returns

true if the Time is greater than the comparator

bool operator>=(const Time &that) const
Parameters

thatTime to compare

Returns

true if the Time is greater than or equal to the comparator

bool operator!=(const Time &that) const
Parameters

thatTime to compare

Returns

true if the Time is not equal to the comparator

bool operator==(const Time &that) const
Parameters

thatTime to compare

Returns

true if the Time is equal to the comparator

bool operator<=(const Time &that) const
Parameters

thatTime to compare

Returns

true if the Time is less than or equal to the comparator

bool operator<(const Time &that) const
Parameters

thatTime to compare

Returns

true if the Time is less than the comparator

Time &operator+=(const Duration &a_ti)
Parameters

a_tiDuration to add

Returns

Time value + Duration

Time &operator-=(const Duration &a_ti)
Parameters

a_tiDuration to subtract

Returns

Time value - Duration

int64_t to_millisecs() const

Returns this Time in milliseconds.

Returns

this Time in milliseconds

int64_t to_microsecs() const

Returns this Time in micro-seconds.

Returns

this Time in micro-seconds

double to_secs() const

Returns this Time in seconds.

Returns

this Time in seconds

Public Static Functions

static const Time invalid()
static const Time from_microsecs(int64_t microseconds)

Create a Time from a number of microseconds

Parameters

microseconds – number of microseconds

static const Time from_millisecs(int64_t milliseconds)

Create a Time from a number of milliseconds

Parameters

milliseconds – number of miliseconds

static const Time from_secs(double seconds)

Create a Time from a number of seconds

Parameters

seconds – number of seconds