C++ Utilities
4.8.0
Common C++ classes and routines used by my applications such as argument parser, IO and conversion utilities
|
Represents a time interval. More...
#include <timespan.h>
Public Member Functions | |
constexpr | TimeSpan () |
Constructs a new instance of the TimeSpan class with zero ticks. More... | |
constexpr | TimeSpan (int64 ticks) |
Constructs a new instance of the TimeSpan class with the specified number of ticks. More... | |
constexpr int64 | totalTicks () const |
Gets the number of ticks that represent the value of the current TimeSpan class. More... | |
constexpr double | totalMilliseconds () const |
Gets the value of the current TimeSpan class expressed in whole and fractional milliseconds. More... | |
constexpr double | totalSeconds () const |
Gets the value of the current TimeSpan class expressed in whole and fractional seconds. More... | |
constexpr double | totalMinutes () const |
Gets the value of the current TimeSpan class expressed in whole and fractional minutes. More... | |
constexpr double | totalHours () const |
Gets the value of the current TimeSpan class expressed in whole and fractional hours. More... | |
constexpr double | totalDays () const |
Gets the value of the current TimeSpan class expressed in whole and fractional days. More... | |
constexpr int | milliseconds () const |
Gets the miliseconds component of the time interval represented by the current TimeSpan class. More... | |
constexpr int | seconds () const |
Gets the seconds component of the time interval represented by the current TimeSpan class. More... | |
constexpr int | minutes () const |
Gets the minutes component of the time interval represented by the current TimeSpan class. More... | |
constexpr int | hours () const |
Gets the hours component of the time interval represented by the current TimeSpan class. More... | |
constexpr int | days () const |
Gets the days component of the time interval represented by the current TimeSpan class. More... | |
constexpr bool | operator== (const TimeSpan &other) const |
Indicates whether two TimeSpan instances are equal. More... | |
constexpr bool | operator!= (const TimeSpan &other) const |
Indicates whether two TimeSpan instances are not equal. More... | |
constexpr bool | operator< (const TimeSpan &other) const |
Indicates whether a specified TimeSpan is less than another specified TimeSpan. More... | |
constexpr bool | operator> (const TimeSpan &other) const |
Indicates whether a specified TimeSpan is greater than another specified TimeSpan. More... | |
constexpr bool | operator<= (const TimeSpan &other) const |
Indicates whether a specified TimeSpan is less or equal than another specified TimeSpan. More... | |
constexpr bool | operator>= (const TimeSpan &other) const |
Indicates whether a specified TimeSpan is greater or equal than another specified TimeSpan. More... | |
constexpr TimeSpan | operator+ (const TimeSpan &other) const |
Adds two TimeSpan instances. More... | |
constexpr TimeSpan | operator- (const TimeSpan &other) const |
Substracts two TimeSpan instances. More... | |
TimeSpan & | operator+= (const TimeSpan &other) |
Adds another TimeSpan to the current instance. More... | |
TimeSpan & | operator-= (const TimeSpan &other) |
Substracts another TimeSpan from the current instance. More... | |
std::string | toString (TimeSpanOutputFormat format=TimeSpanOutputFormat::Normal, bool noMilliseconds=false) const |
Converts the value of the current TimeSpan object to its equivalent std::string representation according the given format. More... | |
void | toString (std::string &result, TimeSpanOutputFormat format=TimeSpanOutputFormat::Normal, bool noMilliseconds=false) const |
Converts the value of the current TimeSpan object to its equivalent std::string representation according the given format. More... | |
constexpr bool | isNull () const |
Returns ture if the time interval represented by the current TimeSpan class is null. More... | |
constexpr bool | isNegative () const |
Returns ture if the time interval represented by the current TimeSpan class is negative. More... | |
constexpr bool | isNegativeInfinity () const |
Returns whether the time inverval represented by the current instance is the smallest representable TimeSpan. More... | |
constexpr bool | isInfinity () const |
Returns whether the time inverval represented by the current instance is the longest representable TimeSpan. More... | |
Static Public Member Functions | |
static constexpr TimeSpan | fromMilliseconds (double milliseconds) |
Constructs a new instance of the TimeSpan class with the specified number of miliseconds. More... | |
static constexpr TimeSpan | fromSeconds (double seconds) |
Constructs a new instance of the TimeSpan class with the specified number of seconds. More... | |
static constexpr TimeSpan | fromMinutes (double minutes) |
Constructs a new instance of the TimeSpan class with the specified number of minutes. More... | |
static constexpr TimeSpan | fromHours (double hours) |
Constructs a new instance of the TimeSpan class with the specified number of hours. More... | |
static constexpr TimeSpan | fromDays (double days) |
Constructs a new instance of the TimeSpan class with the specified number of days. More... | |
static TimeSpan | fromString (const std::string &str, char separator=':') |
Parses the given std::string as TimeSpan. More... | |
static TimeSpan | fromString (const char *str, char separator) |
Parses the given C-style string as TimeSpan. More... | |
static constexpr TimeSpan | negativeInfinity () |
Constructs a new instace of the TimeSpan class with the minimal number of ticks. More... | |
static constexpr TimeSpan | infinity () |
Constructs a new instace of the TimeSpan class with the maximal number of ticks. More... | |
Static Public Attributes | |
static constexpr uint64 | ticksPerMillisecond = 10000uL |
static constexpr uint64 | ticksPerSecond = 10000000uL |
static constexpr uint64 | ticksPerMinute = 600000000uL |
static constexpr uint64 | ticksPerHour = 36000000000uL |
static constexpr uint64 | ticksPerDay = 864000000000uL |
Friends | |
class | DateTime |
Represents a time interval.
Definition at line 27 of file timespan.h.
|
inlineexplicit |
Constructs a new instance of the TimeSpan class with zero ticks.
Definition at line 88 of file timespan.h.
|
inlineexplicit |
Constructs a new instance of the TimeSpan class with the specified number of ticks.
Definition at line 96 of file timespan.h.
|
inline |
Gets the days component of the time interval represented by the current TimeSpan class.
Definition at line 248 of file timespan.h.
|
inlinestatic |
Constructs a new instance of the TimeSpan class with the specified number of days.
Definition at line 136 of file timespan.h.
|
inlinestatic |
Constructs a new instance of the TimeSpan class with the specified number of hours.
Definition at line 128 of file timespan.h.
|
inlinestatic |
Constructs a new instance of the TimeSpan class with the specified number of miliseconds.
Definition at line 104 of file timespan.h.
|
inlinestatic |
Constructs a new instance of the TimeSpan class with the specified number of minutes.
Definition at line 120 of file timespan.h.
|
inlinestatic |
Constructs a new instance of the TimeSpan class with the specified number of seconds.
Definition at line 112 of file timespan.h.
|
inlinestatic |
Parses the given std::string as TimeSpan.
Definition at line 144 of file timespan.h.
|
static |
Parses the given C-style string as TimeSpan.
Definition at line 23 of file timespan.cpp.
|
inline |
Gets the hours component of the time interval represented by the current TimeSpan class.
Definition at line 240 of file timespan.h.
|
inlinestatic |
Constructs a new instace of the TimeSpan class with the maximal number of ticks.
Definition at line 160 of file timespan.h.
|
inline |
Returns whether the time inverval represented by the current instance is the longest representable TimeSpan.
Definition at line 362 of file timespan.h.
|
inline |
Returns ture if the time interval represented by the current TimeSpan class is negative.
Definition at line 346 of file timespan.h.
|
inline |
Returns whether the time inverval represented by the current instance is the smallest representable TimeSpan.
Definition at line 354 of file timespan.h.
|
inline |
Returns ture if the time interval represented by the current TimeSpan class is null.
Definition at line 338 of file timespan.h.
|
inline |
Gets the miliseconds component of the time interval represented by the current TimeSpan class.
Definition at line 216 of file timespan.h.
|
inline |
Gets the minutes component of the time interval represented by the current TimeSpan class.
Definition at line 232 of file timespan.h.
|
inlinestatic |
Constructs a new instace of the TimeSpan class with the minimal number of ticks.
Definition at line 152 of file timespan.h.
|
inline |
Indicates whether two TimeSpan instances are not equal.
Definition at line 264 of file timespan.h.
Adds two TimeSpan instances.
Definition at line 304 of file timespan.h.
Adds another TimeSpan to the current instance.
Definition at line 320 of file timespan.h.
Substracts two TimeSpan instances.
Definition at line 312 of file timespan.h.
Substracts another TimeSpan from the current instance.
Definition at line 329 of file timespan.h.
|
inline |
Indicates whether a specified TimeSpan is less than another specified TimeSpan.
Definition at line 272 of file timespan.h.
|
inline |
Indicates whether a specified TimeSpan is less or equal than another specified TimeSpan.
Definition at line 288 of file timespan.h.
|
inline |
Indicates whether two TimeSpan instances are equal.
Definition at line 256 of file timespan.h.
|
inline |
Indicates whether a specified TimeSpan is greater than another specified TimeSpan.
Definition at line 280 of file timespan.h.
|
inline |
Indicates whether a specified TimeSpan is greater or equal than another specified TimeSpan.
Definition at line 296 of file timespan.h.
|
inline |
Gets the seconds component of the time interval represented by the current TimeSpan class.
Definition at line 224 of file timespan.h.
string TimeSpan::toString | ( | TimeSpanOutputFormat | format = TimeSpanOutputFormat::Normal , |
bool | noMilliseconds = false |
||
) | const |
Converts the value of the current TimeSpan object to its equivalent std::string representation according the given format.
If noMilliseconds is true the time interval will be rounded to full seconds.
Definition at line 64 of file timespan.cpp.
void TimeSpan::toString | ( | std::string & | result, |
TimeSpanOutputFormat | format = TimeSpanOutputFormat::Normal , |
||
bool | noMilliseconds = false |
||
) | const |
Converts the value of the current TimeSpan object to its equivalent std::string representation according the given format.
If noMilliseconds is true the time interval will be rounded to full seconds.
The string representation will be stored in result.
Definition at line 79 of file timespan.cpp.
|
inline |
Gets the value of the current TimeSpan class expressed in whole and fractional days.
Definition at line 208 of file timespan.h.
|
inline |
Gets the value of the current TimeSpan class expressed in whole and fractional hours.
Definition at line 200 of file timespan.h.
|
inline |
Gets the value of the current TimeSpan class expressed in whole and fractional milliseconds.
Definition at line 176 of file timespan.h.
|
inline |
Gets the value of the current TimeSpan class expressed in whole and fractional minutes.
Definition at line 192 of file timespan.h.
|
inline |
Gets the value of the current TimeSpan class expressed in whole and fractional seconds.
Definition at line 184 of file timespan.h.
|
inline |
Gets the number of ticks that represent the value of the current TimeSpan class.
Definition at line 168 of file timespan.h.
|
friend |
Definition at line 28 of file timespan.h.
|
static |
Definition at line 79 of file timespan.h.
|
static |
Definition at line 78 of file timespan.h.
|
static |
Definition at line 75 of file timespan.h.
|
static |
Definition at line 77 of file timespan.h.
|
static |
Definition at line 76 of file timespan.h.