base
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
base::Time Struct Reference

#include <Time.hpp>

Public Types

enum  Resolution { Seconds = 1, Milliseconds = 1000, Microseconds = 1000000 }
 

Public Member Functions

 Time ()
 
bool operator< (Time const &ts) const
 
bool operator> (Time const &ts) const
 
bool operator== (Time const &ts) const
 
bool operator!= (Time const &ts) const
 
bool operator>= (Time const &ts) const
 
bool operator<= (Time const &ts) const
 
Time operator- (Time const &ts) const
 
Time operator+ (Time const &ts) const
 
Time operator/ (int divider) const
 
Time operator* (double factor) const
 
bool isNull () const
 
timeval toTimeval () const
 
std::vector< int > toTimeValues () const
 
std::string toString (base::Time::Resolution resolution=Microseconds, const std::string &mainFormat="%Y%m%d-%H:%M:%S") const
 
double toSeconds () const
 
int64_t toMilliseconds () const
 
int64_t toMicroseconds () const
 

Static Public Member Functions

static Time now ()
 
static Time fromMicroseconds (int64_t value)
 
static Time fromMilliseconds (int64_t value)
 
static Time fromSeconds (int64_t value)
 
static Time fromSeconds (int value)
 
static Time fromSeconds (int64_t value, int microseconds)
 
static Time fromSeconds (double value)
 
static Time max ()
 
static Time fromTimeValues (int year, int month, int day, int hour, int minute, int seconds, int millis, int micros)
 Create time from int Time Values. Creates a time object from the time values (year, month, day ...) given as integer values. This function can be used when the time values are only available as seperated values in numerical form. More...
 
static Time fromString (const std::string &stringTime, Resolution resolution=Microseconds, const std::string &mainFormat="%Y%m%d-%H:%M:%S")
 

Public Attributes

int64_t microseconds
 

Static Public Attributes

static const int UsecPerSec = 1000000LL
 

Member Enumeration Documentation

◆ Resolution

Enumerator
Seconds 
Milliseconds 
Microseconds 

Constructor & Destructor Documentation

◆ Time()

base::Time::Time ( )

Member Function Documentation

◆ fromMicroseconds()

Time base::Time::fromMicroseconds ( int64_t  value)
static

◆ fromMilliseconds()

Time base::Time::fromMilliseconds ( int64_t  value)
static

◆ fromSeconds() [1/4]

Time base::Time::fromSeconds ( int64_t  value)
static

◆ fromSeconds() [2/4]

Time base::Time::fromSeconds ( int  value)
static

◆ fromSeconds() [3/4]

Time base::Time::fromSeconds ( int64_t  value,
int  microseconds 
)
static

◆ fromSeconds() [4/4]

Time base::Time::fromSeconds ( double  value)
static

◆ fromString()

Time base::Time::fromString ( const std::string &  stringTime,
Time::Resolution  resolution = Microseconds,
const std::string &  mainFormat = "%Y%m%d-%H:%M:%S" 
)
static

Create a time object from an input string, by default all parameters are set to convert the string returned by toString back to a Time object.

Parameters
stringTimeString describing the time
resolutionSet to a resolution higher than Secs if a (non-standard) msec or usec field is present, i.e. the non standard field is separated by ':'
mainFormatvalid format for strptime, e.g."%Y%m%d-%H:%M:%S" which the given time string has
Exceptions
std::runtime_erroron failure such as a mismatching format

◆ fromTimeValues()

Time base::Time::fromTimeValues ( int  year,
int  month,
int  day,
int  hour,
int  minute,
int  seconds,
int  millis,
int  micros 
)
static

Create time from int Time Values. Creates a time object from the time values (year, month, day ...) given as integer values. This function can be used when the time values are only available as seperated values in numerical form.

Parameters
yearThe year as integer value. (should be 4 digits)
monthThe month of the year (1..12).
dayDay of the month (1..31).
hourThe hour of the day (since midnight 0..23).
minuteThe minutes after the hour (0..59).
secondsThe seconds after the minute (0..59)
millisMilliseconds after the last second (0..999)
microsMicroseconds additional to the milliseconds (0..999)
Returns
a Time object generated from the parameters.

◆ isNull()

bool base::Time::isNull ( ) const

True if this time is zero

◆ max()

Time base::Time::max ( )
static

Returns the maximum time value possible

◆ now()

Time base::Time::now ( )
static

Returns the current time

◆ operator!=()

bool base::Time::operator!= ( Time const &  ts) const

◆ operator*()

Time base::Time::operator* ( double  factor) const

◆ operator+()

Time base::Time::operator+ ( Time const &  ts) const

◆ operator-()

Time base::Time::operator- ( Time const &  ts) const

◆ operator/()

Time base::Time::operator/ ( int  divider) const

◆ operator<()

bool base::Time::operator< ( Time const &  ts) const

◆ operator<=()

bool base::Time::operator<= ( Time const &  ts) const

◆ operator==()

bool base::Time::operator== ( Time const &  ts) const

◆ operator>()

bool base::Time::operator> ( Time const &  ts) const

◆ operator>=()

bool base::Time::operator>= ( Time const &  ts) const

◆ toMicroseconds()

int64_t base::Time::toMicroseconds ( ) const

Returns this time as an integer number of microseconds

◆ toMilliseconds()

int64_t base::Time::toMilliseconds ( ) const

Returns this time as an integer number of milliseconds (thus dropping the microseconds)

◆ toSeconds()

double base::Time::toSeconds ( ) const

Returns this time as a fractional number of seconds

◆ toString()

std::string base::Time::toString ( base::Time::Resolution  resolution = Microseconds,
const std::string &  mainFormat = "%Y%m%d-%H:%M:%S" 
) const

Convert time into a string

Parameters
resolutionResolution which the string should present
mainFormatMain format to use – this is passed to strftime and appended by ':' plus the below seconds resolution if requested by the resolution argument

◆ toTimeval()

timeval base::Time::toTimeval ( ) const

Converts this time as a timeval object

◆ toTimeValues()

std::vector< int > base::Time::toTimeValues ( ) const

Member Data Documentation

◆ microseconds

int64_t base::Time::microseconds

◆ UsecPerSec

const int base::Time::UsecPerSec = 1000000LL
static

The documentation for this struct was generated from the following files: