1 #ifndef CHRONO_UTILITIES_TIMESPAN_H 2 #define CHRONO_UTILITIES_TIMESPAN_H 4 #include "../conversion/types.h" 33 static constexpr
TimeSpan fromMilliseconds(
double milliseconds);
34 static constexpr
TimeSpan fromSeconds(
double seconds);
35 static constexpr
TimeSpan fromMinutes(
double minutes);
36 static constexpr
TimeSpan fromHours(
double hours);
37 static constexpr
TimeSpan fromDays(
double days);
38 static TimeSpan fromString(
const std::string &str,
char separator =
':');
39 static TimeSpan fromString(
const char *str,
char separator);
40 static constexpr
TimeSpan negativeInfinity();
41 static constexpr
TimeSpan infinity();
43 constexpr
int64 totalTicks()
const;
44 constexpr
double totalMilliseconds()
const;
45 constexpr
double totalSeconds()
const;
46 constexpr
double totalMinutes()
const;
47 constexpr
double totalHours()
const;
48 constexpr
double totalDays()
const;
50 constexpr
int milliseconds()
const;
51 constexpr
int seconds()
const;
52 constexpr
int minutes()
const;
53 constexpr
int hours()
const;
54 constexpr
int days()
const;
57 constexpr
bool operator!=(
const TimeSpan &other)
const;
58 constexpr
bool operator<(
const TimeSpan &other)
const;
59 constexpr
bool operator>(
const TimeSpan &other)
const;
60 constexpr
bool operator<=(
const TimeSpan &other)
const;
61 constexpr
bool operator>=(
const TimeSpan &other)
const;
69 constexpr
bool isNull()
const;
70 constexpr
bool isNegative()
const;
71 constexpr
bool isNegativeInfinity()
const;
72 constexpr
bool isInfinity()
const;
74 static constexpr
uint64 ticksPerMillisecond = 10000uL;
75 static constexpr
uint64 ticksPerSecond = 10000000uL;
76 static constexpr
uint64 ticksPerMinute = 600000000uL;
77 static constexpr
uint64 ticksPerHour = 36000000000uL;
78 static constexpr
uint64 ticksPerDay = 864000000000uL;
153 return TimeSpan(std::numeric_limits<decltype(m_ticks)>::min());
161 return TimeSpan(std::numeric_limits<decltype(m_ticks)>::max());
185 return static_cast<double>(m_ticks) / static_cast<double>(
ticksPerSecond);
193 return static_cast<double>(m_ticks) / static_cast<double>(
ticksPerMinute);
201 return static_cast<double>(m_ticks) / static_cast<double>(
ticksPerHour);
209 return static_cast<double>(m_ticks) / static_cast<double>(
ticksPerDay);
257 return m_ticks == other.m_ticks;
265 return m_ticks != other.m_ticks;
273 return m_ticks < other.m_ticks;
281 return m_ticks > other.m_ticks;
289 return m_ticks <= other.m_ticks;
297 return m_ticks >= other.m_ticks;
305 return TimeSpan(m_ticks + other.m_ticks);
313 return TimeSpan(m_ticks - other.m_ticks);
321 m_ticks += other.m_ticks;
330 m_ticks -= other.m_ticks;
355 return m_ticks == std::numeric_limits<decltype(m_ticks)>::min();
363 return m_ticks == std::numeric_limits<decltype(m_ticks)>::max();
376 #endif // CHRONO_UTILITIES_TIMESPAN_H TimeSpanOutputFormat
Specifies the output format.
constexpr double totalMilliseconds() const
Gets the value of the current TimeSpan class expressed in whole and fractional milliseconds.
static constexpr TimeSpan fromHours(double hours)
Constructs a new instance of the TimeSpan class with the specified number of hours.
static constexpr TimeSpan negativeInfinity()
Constructs a new instace of the TimeSpan class with the minimal number of ticks.
size_t operator()(const ChronoUtilities::TimeSpan &timeSpan) const
std::int64_t int64
signed 64-bit integer
constexpr bool isNegative() const
Returns ture if the time interval represented by the current TimeSpan class is negative.
static constexpr uint64 ticksPerDay
constexpr bool operator<=(const TimeSpan &other) const
Indicates whether a specified TimeSpan is less or equal than another specified TimeSpan.
Represents an instant in time, typically expressed as a date and time of day.
Contains classes providing a means for handling date and time information.
constexpr int64 totalTicks() const
Gets the number of ticks that represent the value of the current TimeSpan class.
constexpr int days() const
Gets the days component of the time interval represented by the current TimeSpan class.
constexpr double totalMinutes() const
Gets the value of the current TimeSpan class expressed in whole and fractional minutes.
Represents a time interval.
constexpr int hours() const
Gets the hours component of the time interval represented by the current TimeSpan class...
static constexpr TimeSpan fromMilliseconds(double milliseconds)
Constructs a new instance of the TimeSpan class with the specified number of miliseconds.
constexpr TimeSpan()
Constructs a new instance of the TimeSpan class with zero ticks.
static constexpr uint64 ticksPerMillisecond
static constexpr TimeSpan fromSeconds(double seconds)
Constructs a new instance of the TimeSpan class with the specified number of seconds.
std::uint64_t uint64
unsigned 64-bit integer
TimeSpan & operator-=(const TimeSpan &other)
Substracts another TimeSpan from the current instance.
constexpr double totalHours() const
Gets the value of the current TimeSpan class expressed in whole and fractional hours.
constexpr bool isNull() const
Returns ture if the time interval represented by the current TimeSpan class is null.
static constexpr uint64 ticksPerHour
constexpr bool operator>=(const TimeSpan &other) const
Indicates whether a specified TimeSpan is greater or equal than another specified TimeSpan...
constexpr bool operator<(const TimeSpan &other) const
Indicates whether a specified TimeSpan is less than another specified TimeSpan.
constexpr int minutes() const
Gets the minutes component of the time interval represented by the current TimeSpan class...
bool operator==(const AsHexNumber< T > &lhs, const AsHexNumber< T > &rhs)
Provides operator == required by CPPUNIT_ASSERT_EQUAL.
constexpr TimeSpan operator-(const TimeSpan &other) const
Substracts two TimeSpan instances.
constexpr int milliseconds() const
Gets the miliseconds component of the time interval represented by the current TimeSpan class...
static constexpr TimeSpan fromDays(double days)
Constructs a new instance of the TimeSpan class with the specified number of days.
constexpr bool isInfinity() const
Returns whether the time inverval represented by the current instance is the longest representable Ti...
constexpr double totalSeconds() const
Gets the value of the current TimeSpan class expressed in whole and fractional seconds.
constexpr bool operator!=(const TimeSpan &other) const
Indicates whether two TimeSpan instances are not equal.
TimeSpan & operator+=(const TimeSpan &other)
Adds another TimeSpan to the current instance.
constexpr int seconds() const
Gets the seconds component of the time interval represented by the current TimeSpan class...
constexpr bool operator==(const TimeSpan &other) const
Indicates whether two TimeSpan instances are equal.
std::string operator+(const Tuple &lhs, const std::string &rhs)
Allows construction of final string from previously constructed string-tuple and trailing string via ...
constexpr double totalDays() const
Gets the value of the current TimeSpan class expressed in whole and fractional days.
constexpr bool operator>(const TimeSpan &other) const
Indicates whether a specified TimeSpan is greater than another specified TimeSpan.
constexpr bool isNegativeInfinity() const
Returns whether the time inverval represented by the current instance is the smallest representable T...
static constexpr uint64 ticksPerSecond
constexpr TimeSpan operator+(const TimeSpan &other) const
Adds two TimeSpan instances.
static constexpr TimeSpan infinity()
Constructs a new instace of the TimeSpan class with the maximal number of ticks.
static TimeSpan fromString(const std::string &str, char separator=':')
Parses the given std::string as TimeSpan.
#define CPP_UTILITIES_EXPORT
Marks the symbol to be exported by the c++utilities library.
static constexpr TimeSpan fromMinutes(double minutes)
Constructs a new instance of the TimeSpan class with the specified number of minutes.
static constexpr uint64 ticksPerMinute