6#include <SimoxUtility/algorithm/string/string_tools.h>
183 std::string unit =
"µs";
185 if (time_count >= 1000)
190 if (time_count >= 1000)
195 if (time_count >= 60)
200 if (time_count >= 60)
205 if (time_count >= 24)
215 std::stringstream ss;
216 ss << std::setprecision(3) << time_count;
217 return ss.str() + unit;
224 const std::int64_t msec =
225 (
static_cast<double>(usec) / 1'000) + 0.5;
226 const time_t
time =
static_cast<time_t
>(
static_cast<double>(
_microSeconds) / 1'000'000);
229 localtime_r(&
time, &tr);
232 if (strftime(buf,
sizeof(buf), format.c_str(), &tr) == 0)
234 return std::string();
237 std::string postformat(buf);
238 postformat = simox::alg::replace_all(postformat,
"%msec", std::to_string(msec));
239 postformat = simox::alg::replace_all(postformat,
"%usec", std::to_string(usec));
286 return *
this *
static_cast<double>(rhs);
292 return *
this *
static_cast<double>(rhs);
305 return *
this *=
static_cast<double>(rhs);
311 return *
this *=
static_cast<double>(rhs);
331 return *
this /
static_cast<double>(rhs);
337 return *
this /
static_cast<double>(rhs);
350 return *
this /=
static_cast<double>(rhs);
356 return *
this /=
static_cast<double>(rhs);
Duration & operator/=(double rhs)
bool operator<=(const Duration &rhs) const
Duration & operator*=(double rhs)
static Duration DaysDouble(double days)
Constructs a duration in days.
static Duration MicroSeconds(std::int64_t microSeconds)
Constructs a duration in microseconds.
static Duration MicroSecondsDouble(double microSeconds)
Constructs a duration in microseconds.
static Duration Minutes(std::int64_t minutes)
Constructs a duration in minutes.
double operator/(const Duration &rhs) const
Duration & operator+=(const Duration &rhs)
static Duration Hours(std::int64_t hours)
Constructs a duration in hours.
std::int64_t toHours() const
Returns the amount of hours.
Duration operator+(const Duration &rhs) const
static Duration Seconds(std::int64_t seconds)
Constructs a duration in seconds.
bool operator>(const Duration &rhs) const
static Duration MinutesDouble(double minutes)
Constructs a duration in minutes.
std::int64_t toMinutes() const
Returns the amount of minutes.
static Duration SecondsDouble(double seconds)
Constructs a duration in seconds.
std::int64_t toDays() const
Returns the amount of days.
double toHoursDouble() const
Returns the amount of hours.
bool operator>=(const Duration &rhs) const
std::int64_t toMilliSeconds() const
Returns the amount of milliseconds.
double toSecondsDouble() const
Returns the amount of seconds.
static Duration HoursDouble(double hours)
Constructs a duration in hours.
std::int64_t toMicroSeconds() const
Returns the amount of microseconds.
bool operator!=(const Duration &rhs) const
double toMilliSecondsDouble() const
Returns the amount of milliseconds.
Duration & operator-=(const Duration &rhs)
double toDaysDouble() const
Returns the amount of days.
bool operator==(const Duration &rhs) const
Duration operator*(double rhs) const
std::int64_t _microSeconds
Current duration in microseconds.
static Duration MilliSeconds(std::int64_t milliSeconds)
Constructs a duration in milliseconds.
bool isPositive() const
Tests whether the duration is positive (value in µs > 0).
double toMinutesDouble() const
Returns the amount of minutes.
static Duration Days(std::int64_t days)
Constructs a duration in days.
Duration operator-() const
double toMicroSecondsDouble() const
Returns the amount of microseconds.
static Duration MilliSecondsDouble(double milliSeconds)
Constructs a duration in milliseconds.
bool operator<(const Duration &rhs) const
std::int64_t toSeconds() const
Returns the amount of seconds.
Duration()
Constructs a zero-duration.
std::string toDurationString() const
String representation of the current duration in minimal/default format.
std::ostream & operator<<(std::ostream &out, const DateTime &rhs)