OnixS EBS BrokerTec Market Data and Trading Handler for C++  2.14.1.0
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
TimeSpan Class Reference

Represents time interval. More...

Public Member Functions

 TimeSpan ()
 Initializes zero span.
 
 TimeSpan (int hours, int minutes, int seconds, int nanoseconds=0)
 Initializes with given set of values. More...
 
 TimeSpan (int days, int hours, int minutes, int seconds, int nanoseconds)
 Initializes with given set of values. More...
 
 TimeSpan (long long totalSeconds, int nanoseconds)
 Initializes time interval from total number seconds and its fractional (nanosecond) part. More...
 
 TimeSpan (const TimeSpan &other)
 Initializes as clone of other instance.
 
long long totalSeconds () const
 Whole number of seconds in time interval.
 
int days () const
 Days component of time interval. More...
 
int hours () const
 Hours component of time interval. More...
 
int minutes () const
 Minutes component of time interval. More...
 
int seconds () const
 Seconds component of time interval. More...
 
int milliseconds () const
 Milliseconds component of time interval. More...
 
int microseconds () const
 Microseconds component of time interval. More...
 
int nanoseconds () const
 Nanoseconds component of time interval. More...
 
bool operator== (const TimeSpan &other) const
 Compares with other instance for equality.
 
bool operator!= (const TimeSpan &other) const
 Compares with other instance for in-equality.
 
bool operator< (const TimeSpan &other) const
 Checks whether time interval less than other one.
 
bool operator> (const TimeSpan &other) const
 Checks whether time interval greater than other one.
 
TimeSpanoperator+= (const TimeSpan &other)
 Adds time interval to current one.
 
TimeSpanoperator-= (const TimeSpan &other)
 Subtracts time interval from current one.
 
TimeSpanoperator= (const TimeSpan &other)
 Re-assigns time interval from other one.
 
void toString (std::string &str, TimeSpanFormat format=TimeSpanFormats::SDHHMMSSnsec) const
 Serializes time stamp into text presentation using specified time-span presentation format. More...
 
std::string toString (TimeSpanFormat format=TimeSpanFormats::SDHHMMSSnsec) const
 Serializes time stamp into text presentation using specified time-span presentation format. More...
 

Static Public Member Functions

static TimeSpan deserialize (const std::string &str)
 De-serializes time interval from its text presentation.
 
static TimeSpan deserialize (unsigned long long presentation, TimeSpanFormat format)
 De-serializes time-span from presentation as it's used by the exchange.
 

Static Public Attributes

static const TimeSpan Zero
 Time interval of zero length.
 

Detailed Description

Represents time interval.

Used primarily to present time-only stamps and to measure time intervals between two timestamps.

Constructor & Destructor Documentation

TimeSpan ( int  hours,
int  minutes,
int  seconds,
int  nanoseconds = 0 
)

Initializes with given set of values.

Input parameters are treated as quantities, but not as a time stamp. Therefore, there's no requirement to fit in a certain range like hours must fit into [0, 24) range. After initialization time span will be normalized.

TimeSpan ( int  days,
int  hours,
int  minutes,
int  seconds,
int  nanoseconds 
)

Initializes with given set of values.

Input parameters are treated as quantities, but not as a time stamp. Therefore, there's no requirement to fit in a certain range like hours must fit into [0, 24) range. After initialization time span will be normalized.

TimeSpan ( long long  totalSeconds,
int  nanoseconds 
)

Initializes time interval from total number seconds and its fractional (nanosecond) part.

Member Function Documentation

int days ( ) const

Days component of time interval.

Whole number of days in time interval.

int hours ( ) const

Hours component of time interval.

Values are in range from -23 through 23.

int microseconds ( ) const

Microseconds component of time interval.

Values are in range from -999999 through 999999.

int milliseconds ( ) const

Milliseconds component of time interval.

Values are in range from -999 through 999.

int minutes ( ) const

Minutes component of time interval.

Values are in range from -59 through 59.

int nanoseconds ( ) const
inline

Nanoseconds component of time interval.

Values are in range from -999999999 through 999999999.

int seconds ( ) const

Seconds component of time interval.

Values are in range from -59 through 59.

void toString ( std::string &  str,
TimeSpanFormat  format = TimeSpanFormats::SDHHMMSSnsec 
) const

Serializes time stamp into text presentation using specified time-span presentation format.

std::string toString ( TimeSpanFormat  format = TimeSpanFormats::SDHHMMSSnsec) const
inline

Serializes time stamp into text presentation using specified time-span presentation format.