1#define CHRONO_UTILITIES_TIMESPAN_INTEGER_SCALE_OVERLOADS
5#include "../conversion/stringconversion.h"
46 for (
const char *
i = str; *
i; ++
i) {
47 *
i == separator && ++partsSize;
49 parts.reserve(partsSize);
51 for (
const char *
i = str;;) {
52 if (*
i == separator) {
53 parts.emplace_back(stringToNumber<double>(
string(str,
i)));
55 }
else if (*
i ==
'\0') {
56 parts.emplace_back(stringToNumber<double>(
string(str,
i)));
63 switch (parts.size()) {
85 stringstream s(stringstream::in | stringstream::out);
89 positive.m_ticks = -positive.m_ticks;
93 s << setfill(
'0') << setw(2) << floor(positive.
totalHours()) <<
":" << setw(2) << positive.
minutes() <<
":" << setw(2) << positive.
seconds();
98 if (milli || micro || nano) {
99 s <<
'.' << setw(3) << milli;
101 s << setw(3) << micro;
117 bool needWhitespace =
false;
118 if (
const int days = positive.
days()) {
119 needWhitespace =
true;
125 needWhitespace =
true;
131 needWhitespace =
true;
137 needWhitespace =
true;
144 needWhitespace =
true;
150 needWhitespace =
true;
164 s << setprecision(0);
166 s << setprecision(10);
Represents a time interval.
constexpr double totalHours() const
Returns the value of the current TimeSpan class expressed in whole and fractional hours.
constexpr double totalSeconds() const
Returns the value of the current TimeSpan class expressed in whole and fractional seconds.
constexpr bool isNull() const
Returns true if the time interval represented by the current TimeSpan class is null.
static constexpr TickType nanosecondsPerTick
constexpr int seconds() const
Returns the seconds component of the time interval represented by the current TimeSpan class.
constexpr int minutes() const
Returns the minutes component of the time interval represented by the current TimeSpan class.
constexpr double totalMicroseconds() const
Returns the value of the current TimeSpan class expressed in whole and fractional microseconds.
constexpr TimeSpan()
Constructs a new instance of the TimeSpan class with zero ticks.
constexpr int days() const
Returns the days component of the time interval represented by the current TimeSpan class.
constexpr int milliseconds() const
Returns the milliseconds 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.
static constexpr TimeSpan fromHours(double hours)
Constructs a new instance of the TimeSpan class with the specified number of hours.
static constexpr TimeSpan fromMinutes(double minutes)
Constructs a new instance of the TimeSpan class with the specified number of minutes.
static constexpr TimeSpan fromSeconds(double seconds)
Constructs a new instance of the TimeSpan class with the specified number of seconds.
constexpr int microseconds() const
Returns the microseconds component of the time interval represented by the current TimeSpan class.
std::string toString(TimeSpanOutputFormat format=TimeSpanOutputFormat::Normal, bool fullSeconds=false) const
Converts the value of the current TimeSpan object to its equivalent std::string representation accord...
static TimeSpan fromString(const std::string &str, char separator=':')
Parses the given std::string as TimeSpan.
constexpr double totalMilliseconds() const
Returns the value of the current TimeSpan class expressed in whole and fractional milliseconds.
constexpr bool isNegative() const
Returns true if the time interval represented by the current TimeSpan class is negative.
constexpr int hours() const
Returns the hours component of the time interval represented by the current TimeSpan class.
constexpr int nanoseconds() const
Returns the nanoseconds component of the time interval represented by the current TimeSpan class.
Contains all utilities provides by the c++utilities library.
TimeSpanOutputFormat
Specifies the output format.