KanoopCommonQt 2.1.1
Kanoop foundational Qt utility library
Loading...
Searching...
No Matches
timespan.h
1/**
2 * TimeSpan
3 *
4 * This class represents a span of time with nanosecond resolution, and provides
5 * an interface that is very similar to the .NET TimeSpan class.
6 *
7 * Operators are supplied for comparison and assignment.
8 *
9 * Conversions are supplied to convert between timespec and TimeSpan.
10 *
11 * Use the absDiff() static method to obtain the difference between two
12 * QDateTime objects.
13 *
14 * NOTE:
15 * The underlying representation is a signed 64-bit integer value of nanoseconds.
16 * Therefore, the largest possible value is 9,223,372,036,854,775,807 giving a
17 * maximum range of approximately 292 years.
18 *
19 * This was re-written December 2021 to have nanosecond resolution. The interface
20 * is compatible with the previous TimeSpan object.
21 *
22 * Stephen Punak, December 27 2021
23 */
24#ifndef TIMESPAN_H_
25#define TIMESPAN_H_
26#include <QString>
27#include <QObject>
28#include <QDateTime>
29#include <time.h>
30#include <sys/time.h>
31#include "kanoopcommon.h"
32
33/**
34 * @brief A signed 64-bit nanosecond-resolution duration value, similar to the .NET TimeSpan class.
35 *
36 * Provides arithmetic, comparison, and conversion operations across all common time units.
37 * The underlying storage is a signed 64-bit nanosecond count, giving a maximum range of
38 * approximately 292 years. Use the static factory methods (fromSeconds(), fromMilliseconds(),
39 * etc.) or absDiff() to construct instances conveniently.
40 */
41class KANOOP_EXPORT TimeSpan
42{
43public:
44 /** @brief Default constructor — creates a zero-length time span. */
46 _nanoseconds(0) {}
47
48 /**
49 * @brief Construct a TimeSpan from explicit time components.
50 * @param days Number of days
51 * @param hours Number of hours
52 * @param minutes Number of minutes
53 * @param seconds Number of seconds
54 * @param milliseconds Number of milliseconds (default 0)
55 * @param microseconds Number of microseconds (default 0)
56 * @param nanoseconds Number of nanoseconds (default 0)
57 */
58 TimeSpan(double days, double hours, double minutes, double seconds, double milliseconds = 0, double microseconds = 0, double nanoseconds = 0);
59
60 /**
61 * @brief Copy constructor.
62 * @param other TimeSpan to copy
63 */
64 TimeSpan(const TimeSpan& other);
65
66 /**
67 * @brief Construct a TimeSpan from a POSIX timespec value.
68 * @param other timespec containing tv_sec and tv_nsec fields
69 */
70 TimeSpan(const timespec& other);
71
72 /**
73 * @brief Copy-assign from another TimeSpan.
74 * @param other TimeSpan to copy
75 * @return Reference to this TimeSpan
76 */
77 TimeSpan& operator=(const TimeSpan& other);
78 /**
79 * @brief Assign from a POSIX timespec.
80 * @param other timespec to assign from
81 * @return Reference to this TimeSpan
82 */
83 TimeSpan& operator=(const timespec& other);
84
85 /**
86 * @brief Add two time spans.
87 * @param other TimeSpan to add
88 * @return Sum of both time spans
89 */
90 TimeSpan operator+(const TimeSpan& other) const;
91 /**
92 * @brief Subtract a time span.
93 * @param other TimeSpan to subtract
94 * @return Difference of both time spans
95 */
96 TimeSpan operator-(const TimeSpan& other) const;
97 /**
98 * @brief Multiply two time spans component-wise.
99 * @param other TimeSpan to multiply by
100 * @return Product
101 */
102 TimeSpan operator*(const TimeSpan& other) const;
103 /**
104 * @brief Scale by a scalar factor.
105 * @param value Scalar multiplier
106 * @return Scaled time span
107 */
108 TimeSpan operator*(double value) const;
109 /**
110 * @brief Divide two time spans component-wise.
111 * @param other TimeSpan divisor
112 * @return Quotient
113 */
114 TimeSpan operator/(const TimeSpan& other) const;
115 /**
116 * @brief Divide by a scalar factor.
117 * @param value Scalar divisor
118 * @return Scaled time span
119 */
120 TimeSpan operator/(double value) const;
121 /**
122 * @brief Add-assign a TimeSpan.
123 * @param other TimeSpan to add
124 */
125 void operator+=(const TimeSpan& other);
126 /**
127 * @brief Subtract-assign a TimeSpan.
128 * @param other TimeSpan to subtract
129 */
130 void operator-=(const TimeSpan& other);
131 /**
132 * @brief Multiply-assign by a TimeSpan.
133 * @param other TimeSpan to multiply by
134 */
135 void operator*=(const TimeSpan& other);
136 /**
137 * @brief Divide-assign by a TimeSpan.
138 * @param other TimeSpan divisor
139 */
140 void operator/=(const TimeSpan& other);
141 /**
142 * @brief Multiply-assign by a scalar.
143 * @param value Scalar multiplier
144 */
145 void operator*=(double value);
146 /**
147 * @brief Divide-assign by a scalar.
148 * @param value Scalar divisor
149 */
150 void operator/=(double value);
151
152 /**
153 * @brief Equality comparison.
154 * @param other TimeSpan to compare with
155 * @return true if both time spans are equal
156 */
157 bool operator==(const TimeSpan& other) const;
158 /**
159 * @brief Inequality comparison.
160 * @param other TimeSpan to compare with
161 * @return true if both time spans differ
162 */
163 bool operator!=(const TimeSpan& other) const;
164 /**
165 * @brief Greater-than comparison.
166 * @param other TimeSpan to compare with
167 * @return true if this time span is greater
168 */
169 bool operator>(const TimeSpan& other) const;
170 /**
171 * @brief Less-than comparison.
172 * @param other TimeSpan to compare with
173 * @return true if this time span is less
174 */
175 bool operator<(const TimeSpan& other) const;
176 /**
177 * @brief Greater-than-or-equal comparison.
178 * @param other TimeSpan to compare with
179 * @return true if this time span is greater or equal
180 */
181 bool operator>=(const TimeSpan& other) const;
182 /**
183 * @brief Less-than-or-equal comparison.
184 * @param other TimeSpan to compare with
185 * @return true if this time span is less or equal
186 */
187 bool operator<=(const TimeSpan& other) const;
188
189 /**
190 * @brief Output format for toString().
191 */
192 enum Format {
193 Auto, ///< Choose format automatically based on the span's magnitude
194 Milliseconds, ///< Display with millisecond precision
195 MicroSeconds, ///< Display with microsecond precision
196 Abbreviated, ///< Abbreviated format (e.g. "1h 2m 3s")
197 NoMilliseconds, ///< Display without sub-second components
198 };
199
200 /**
201 * @brief Return the number of whole days in the days field of this TimeSpan when printed.
202 * @return Number of whole days
203 */
204 qint64 days() const;
205
206 /**
207 * @brief hours
208 * @return Number of hours represented in the hours field of this TimeSpan when printed
209 */
210 qint64 hours() const;
211
212 /**
213 * @brief minutes
214 * @return Number of hours represented in the minutes field of this TimeSpan when printed
215 */
216 qint64 minutes() const;
217
218 /**
219 * @brief seconds
220 * @return Number of seconds represented in the seconds field of this TimeSpan when printed
221 */
222 qint64 seconds() const;
223
224 /**
225 * @brief milliseconds
226 * @return Number of milliseconds represented in the miliseconds field of this TimeSpan when printed
227 */
228 qint64 milliseconds() const;
229
230 /**
231 * @brief microseconds
232 * @return Number of microseconds represented in the microseconds field of this TimeSpan when printed
233 */
234 qint64 microseconds() const;
235
236 /**
237 * @brief nanoseconds
238 * @return Number of nanoseconds represented in the nanoseconds field of this TimeSpan when printed
239 */
240 qint64 nanoseconds() const;
241
242 /**
243 * @brief totalSeconds
244 * @return The total number of seconds represented in the TimeSpan
245 */
246 double totalSeconds() const;
247
248 /**
249 * @brief totalMinutes
250 * @return The total number of minutes represented in the TimeSpan
251 */
252 double totalMinutes() const;
253
254 /**
255 * @brief totalHours
256 * @return The total number of hours represented in the TimeSpan
257 */
258 double totalHours() const;
259
260 /**
261 * @brief totalDays
262 * @return The total number of days represented in the TimeSpan
263 */
264 double totalDays() const;
265
266 /**
267 * @brief totalMilliseconds
268 * @return The total number of milliseconds represented in the TimeSpan
269 */
270 double totalMilliseconds() const;
271
272 /**
273 * @brief totalMicroseconds
274 * @return The total number of microseconds represented in the TimeSpan
275 */
276 double totalMicroseconds() const;
277
278 /**
279 * @brief totalNanoseconds
280 * @return The total number of nanoseconds represented in the TimeSpan
281 */
282 double totalNanoseconds() const;
283
284 /**
285 * @brief Is this timespan zero total nanoseconds
286 * @return true if this timespan is zero
287 */
288 bool isZero() const { return _nanoseconds == 0; }
289 /**
290 * @brief Return true if this time span represents a negative duration.
291 * @return true if negative
292 */
293 bool isNegative() const { return _nanoseconds < 0; }
294 /**
295 * @brief Return true if this time span represents a positive (non-zero) duration.
296 * @return true if positive
297 */
298 bool isPositive() const { return _nanoseconds > 0; }
299 /**
300 * @brief Return the absolute value of this time span.
301 * @return Non-negative copy of this TimeSpan
302 */
304
305 /**
306 * @brief Return true if this time span was successfully constructed or parsed.
307 * @return true if valid
308 */
309 bool isValid() const { return _valid; }
310
311 /**
312 * @brief Populate a POSIX timespec structure from this TimeSpan.
313 * @param timespec Output timespec to fill with tv_sec and tv_nsec
314 */
315 void toTimeSpec(struct timespec& timespec) const;
316
317 /**
318 * @brief Format this TimeSpan as a string in the specified format.
319 * @param format Display format
320 * @param microseconds If true, include microsecond resolution
321 * @return Formatted duration string
322 */
323 QString toString(Format format, bool microseconds = false) const;
324
325 /**
326 * @brief Format this TimeSpan as a string using the Auto format.
327 * @param microseconds If true, include microsecond resolution
328 * @return Formatted duration string
329 */
330 QString toString(bool microseconds = false) const;
331
332 /**
333 * @brief Format this TimeSpan using the abbreviated display format (e.g. "1h 2m 3s").
334 * @param showMilliseconds If true, append milliseconds to the output
335 * @return Abbreviated duration string
336 */
337 QString toAbbreviatedFormat(bool showMilliseconds = false) const;
338
339 /**
340 * @brief Format this TimeSpan as a verbose diagnostic string showing all internal fields.
341 * @return Diagnostic dump string
342 */
343 QString toDumpString() const;
344
345 /**
346 * @brief Return a new TimeSpan with nanoseconds added.
347 * @param nanoseconds Nanoseconds to add
348 * @return Adjusted TimeSpan
349 */
350 TimeSpan addNanoseconds(double nanoseconds) const;
351
352 /**
353 * @brief Return a new TimeSpan with microseconds added.
354 * @param microseconds Microseconds to add
355 * @return Adjusted TimeSpan
356 */
357 TimeSpan addMicroseconds(double microseconds) const;
358
359 /**
360 * @brief Return a new TimeSpan with milliseconds added.
361 * @param milliseconds Milliseconds to add
362 * @return Adjusted TimeSpan
363 */
364 TimeSpan addMilliseconds(double milliseconds) const;
365
366 /**
367 * @brief Return a new TimeSpan with seconds added.
368 * @param seconds Seconds to add
369 * @return Adjusted TimeSpan
370 */
371 TimeSpan addSeconds(double seconds) const;
372
373 /**
374 * @brief Return a new TimeSpan with minutes added.
375 * @param minutes Minutes to add
376 * @return Adjusted TimeSpan
377 */
378 TimeSpan addMinutes(double minutes) const;
379
380 /**
381 * @brief Return a new TimeSpan with hours added.
382 * @param hours Hours to add
383 * @return Adjusted TimeSpan
384 */
385 TimeSpan addHours(double hours) const;
386
387 /**
388 * @brief Return a new TimeSpan with days added.
389 * @param days Days to add
390 * @return Adjusted TimeSpan
391 */
392 TimeSpan addDays(double days) const;
393
394 /**
395 * @brief Construct a TimeSpan from a QVariant holding a TimeSpan value.
396 * @param value Variant containing a TimeSpan
397 * @return Extracted TimeSpan
398 */
399 static TimeSpan fromVariant(const QVariant& value) { return value.value<TimeSpan>(); }
400
401 /**
402 * @brief Wrap this TimeSpan in a QVariant for storage or signal passing.
403 * @return QVariant containing this TimeSpan
404 */
405 QVariant toVariant() const { return QVariant::fromValue<TimeSpan>(*this); }
406
407 /**
408 * @brief Construct a TimeSpan from a nanosecond count.
409 * @param nanoseconds Duration in nanoseconds
410 * @return TimeSpan
411 */
412 static TimeSpan fromNanoseconds(double nanoseconds);
413
414 /**
415 * @brief Construct a TimeSpan from a microsecond count.
416 * @param microseconds Duration in microseconds
417 * @return TimeSpan
418 */
419 static TimeSpan fromMicroseconds(double microseconds);
420
421 /**
422 * @brief Construct a TimeSpan from a millisecond count.
423 * @param milliseconds Duration in milliseconds
424 * @return TimeSpan
425 */
426 static TimeSpan fromMilliseconds(double milliseconds);
427
428 /**
429 * @brief Construct a TimeSpan from a second count.
430 * @param seconds Duration in seconds
431 * @return TimeSpan
432 */
433 static TimeSpan fromSeconds(double seconds);
434
435 /**
436 * @brief Construct a TimeSpan from a minute count.
437 * @param minutes Duration in minutes
438 * @return TimeSpan
439 */
440 static TimeSpan fromMinutes(double minutes);
441
442 /**
443 * @brief Construct a TimeSpan from an hour count.
444 * @param hours Duration in hours
445 * @return TimeSpan
446 */
447 static TimeSpan fromHours(double hours);
448
449 /**
450 * @brief Construct a TimeSpan from a day count.
451 * @param days Duration in days
452 * @return TimeSpan
453 */
454 static TimeSpan fromDays(double days);
455
456 /**
457 * @brief Parse a TimeSpan from a formatted duration string.
458 * @param timeString String representation of a time span
459 * @param parsed Optional output flag set to true if parsing succeeded
460 * @return Parsed TimeSpan, or an invalid sentinel on failure
461 */
462 static TimeSpan fromString(const QString& timeString, bool* parsed = nullptr);
463
464 /**
465 * @brief Return a zero-length TimeSpan.
466 * @return Zero-length TimeSpan
467 */
468 static TimeSpan zero() { return TimeSpan::fromSeconds(0); }
469
470 /**
471 * @brief Return an invalid (sentinel) TimeSpan whose isValid() returns false.
472 * @return Invalid TimeSpan
473 */
475
476 /**
477 * @brief Compute the signed difference between two QDateTime values (now − then).
478 * @param now Minuend QDateTime
479 * @param then Subtrahend QDateTime
480 * @return Signed difference TimeSpan
481 */
482 static TimeSpan diff(const QDateTime& now, const QDateTime& then);
483
484 /**
485 * @brief Compute the signed difference between two chrono time points (now − then).
486 * @param now Minuend time point
487 * @param then Subtrahend time point
488 * @return Signed difference TimeSpan
489 */
490 static TimeSpan diff(std::chrono::system_clock::time_point now, std::chrono::system_clock::time_point then);
491
492 /**
493 * @brief Compute the absolute (non-negative) difference between two QDateTime values.
494 * @param t1 First QDateTime
495 * @param t2 Second QDateTime
496 * @return Non-negative difference TimeSpan
497 */
498 static TimeSpan absDiff(const QDateTime& t1, const QDateTime& t2);
499
500 /**
501 * @brief Compute the absolute difference between two chrono time points.
502 * @param t1 First time point
503 * @param t2 Second time point
504 * @return Non-negative difference TimeSpan
505 */
506 static TimeSpan absDiff(std::chrono::system_clock::time_point t1, std::chrono::system_clock::time_point t2);
507
508 /**
509 * @brief Return the larger of two time spans.
510 * @param t1 First TimeSpan
511 * @param t2 Second TimeSpan
512 * @return The greater of t1 and t2
513 */
514 static TimeSpan max(const TimeSpan& t1, const TimeSpan& t2) { return t1 > t2 ? t1 : t2; }
515
516 /**
517 * @brief Return the smaller of two time spans.
518 * @param t1 First TimeSpan
519 * @param t2 Second TimeSpan
520 * @return The lesser of t1 and t2
521 */
522 static TimeSpan min(const TimeSpan& t1, const TimeSpan& t2) { return t1 < t2 ? t1 : t2; }
523
524private:
525 static TimeSpan parseAbbreviatedString(const QString& timeString, bool* parsed = nullptr);
526 static TimeSpan parseColonDelimitedString(const QString& timeString, bool* parsed = nullptr);
527 static TimeSpan parseMicrosecondString(const QString& timeString, bool* parsed = nullptr);
528 static TimeSpan parseMillisecondString(const QString& timeString, bool* parsed = nullptr);
529 static QStringList getTokens(const QString &timeString);
530 static int parseIntToToken(QString &remaining, const QString &until);
531
532 qint64 _nanoseconds;
533 bool _valid = true;
534
535// Constants
536 static const double NanosecondsPerMicrosecond;
537 static const double NanosecondsPerMillisecond;
538 static const double NanosecondsPerSecond;
539 static const double NanosecondsPerMinute;
540 static const double NanosecondsPerHour;
541 static const double NanosecondsPerDay;
542
543 static const double MicrosecondsPerMillisecond;
544 static const double MicrosecondsPerSecond;
545 static const double MicrosecondsPerMinute;
546 static const double MicrosecondsPerHour;
547 static const double MicrosecondsPerDay;
548
549 static const double MillisecondsPerSecond;
550 static const double MillisecondsPerMinute;
551 static const double MillisecondsPerHour;
552 static const double MillisecondsPerDay;
553
554 static const double SecondsPerMinute;
555 static const double SecondsPerHour;
556 static const double SecondsPerDay;
557
558 static const double MinutesPerHour;
559 static const double MinutesPerDay;
560
561 static const double HoursPerDay;
562
563 static const double DaysPerYear;
564};
565
566Q_DECLARE_METATYPE(TimeSpan)
567
568#endif /* TIMESPAN_H_ */
TimeSpan.
Definition timespan.h:42
void operator/=(const TimeSpan &other)
Divide-assign by a TimeSpan.
static TimeSpan fromVariant(const QVariant &value)
Construct a TimeSpan from a QVariant holding a TimeSpan value.
Definition timespan.h:399
bool isPositive() const
Return true if this time span represents a positive (non-zero) duration.
Definition timespan.h:298
static TimeSpan fromNanoseconds(double nanoseconds)
Construct a TimeSpan from a nanosecond count.
qint64 minutes() const
minutes
bool isZero() const
Is this timespan zero total nanoseconds.
Definition timespan.h:288
qint64 days() const
Return the number of whole days in the days field of this TimeSpan when printed.
TimeSpan addNanoseconds(double nanoseconds) const
Return a new TimeSpan with nanoseconds added.
static TimeSpan absDiff(const QDateTime &t1, const QDateTime &t2)
Compute the absolute (non-negative) difference between two QDateTime values.
static TimeSpan fromMilliseconds(double milliseconds)
Construct a TimeSpan from a millisecond count.
TimeSpan(double days, double hours, double minutes, double seconds, double milliseconds=0, double microseconds=0, double nanoseconds=0)
Construct a TimeSpan from explicit time components.
static TimeSpan fromString(const QString &timeString, bool *parsed=nullptr)
Parse a TimeSpan from a formatted duration string.
TimeSpan addHours(double hours) const
Return a new TimeSpan with hours added.
static TimeSpan fromDays(double days)
Construct a TimeSpan from a day count.
TimeSpan & operator=(const timespec &other)
Assign from a POSIX timespec.
static TimeSpan fromMicroseconds(double microseconds)
Construct a TimeSpan from a microsecond count.
qint64 seconds() const
seconds
TimeSpan addMicroseconds(double microseconds) const
Return a new TimeSpan with microseconds added.
double totalMicroseconds() const
totalMicroseconds
TimeSpan operator/(double value) const
Divide by a scalar factor.
TimeSpan addMinutes(double minutes) const
Return a new TimeSpan with minutes added.
TimeSpan & operator=(const TimeSpan &other)
Copy-assign from another TimeSpan.
QVariant toVariant() const
Wrap this TimeSpan in a QVariant for storage or signal passing.
Definition timespan.h:405
TimeSpan operator+(const TimeSpan &other) const
Add two time spans.
qint64 nanoseconds() const
nanoseconds
double totalDays() const
totalDays
TimeSpan addDays(double days) const
Return a new TimeSpan with days added.
double totalMinutes() const
totalMinutes
double totalMilliseconds() const
totalMilliseconds
bool isNegative() const
Return true if this time span represents a negative duration.
Definition timespan.h:293
static TimeSpan min(const TimeSpan &t1, const TimeSpan &t2)
Return the smaller of two time spans.
Definition timespan.h:522
bool operator<=(const TimeSpan &other) const
Less-than-or-equal comparison.
TimeSpan(const timespec &other)
Construct a TimeSpan from a POSIX timespec value.
TimeSpan operator/(const TimeSpan &other) const
Divide two time spans component-wise.
void operator*=(const TimeSpan &other)
Multiply-assign by a TimeSpan.
TimeSpan(const TimeSpan &other)
Copy constructor.
static TimeSpan max(const TimeSpan &t1, const TimeSpan &t2)
Return the larger of two time spans.
Definition timespan.h:514
TimeSpan operator*(const TimeSpan &other) const
Multiply two time spans component-wise.
static TimeSpan fromHours(double hours)
Construct a TimeSpan from an hour count.
qint64 milliseconds() const
milliseconds
void toTimeSpec(struct timespec &timespec) const
Populate a POSIX timespec structure from this TimeSpan.
bool operator==(const TimeSpan &other) const
Equality comparison.
double totalSeconds() const
totalSeconds
void operator+=(const TimeSpan &other)
Add-assign a TimeSpan.
qint64 hours() const
hours
double totalHours() const
totalHours
bool operator!=(const TimeSpan &other) const
Inequality comparison.
TimeSpan()
Default constructor — creates a zero-length time span.
Definition timespan.h:45
static TimeSpan zero()
Return a zero-length TimeSpan.
Definition timespan.h:468
void operator/=(double value)
Divide-assign by a scalar.
QString toString(bool microseconds=false) const
Format this TimeSpan as a string using the Auto format.
static TimeSpan diff(std::chrono::system_clock::time_point now, std::chrono::system_clock::time_point then)
Compute the signed difference between two chrono time points (now − then).
bool operator<(const TimeSpan &other) const
Less-than comparison.
TimeSpan operator-(const TimeSpan &other) const
Subtract a time span.
bool operator>=(const TimeSpan &other) const
Greater-than-or-equal comparison.
Format
Output format for toString().
Definition timespan.h:192
@ Milliseconds
Display with millisecond precision.
Definition timespan.h:194
@ NoMilliseconds
Display without sub-second components.
Definition timespan.h:197
@ Abbreviated
Abbreviated format (e.g. "1h 2m 3s")
Definition timespan.h:196
@ MicroSeconds
Display with microsecond precision.
Definition timespan.h:195
@ Auto
Choose format automatically based on the span's magnitude.
Definition timespan.h:193
TimeSpan operator*(double value) const
Scale by a scalar factor.
static TimeSpan diff(const QDateTime &now, const QDateTime &then)
Compute the signed difference between two QDateTime values (now − then).
qint64 microseconds() const
microseconds
bool isValid() const
Return true if this time span was successfully constructed or parsed.
Definition timespan.h:309
void operator*=(double value)
Multiply-assign by a scalar.
QString toAbbreviatedFormat(bool showMilliseconds=false) const
Format this TimeSpan using the abbreviated display format (e.g.
static TimeSpan fromSeconds(double seconds)
Construct a TimeSpan from a second count.
QString toString(Format format, bool microseconds=false) const
Format this TimeSpan as a string in the specified format.
double totalNanoseconds() const
totalNanoseconds
TimeSpan addSeconds(double seconds) const
Return a new TimeSpan with seconds added.
TimeSpan absoluteValue() const
Return the absolute value of this time span.
static TimeSpan invalid()
Return an invalid (sentinel) TimeSpan whose isValid() returns false.
static TimeSpan fromMinutes(double minutes)
Construct a TimeSpan from a minute count.
TimeSpan addMilliseconds(double milliseconds) const
Return a new TimeSpan with milliseconds added.
void operator-=(const TimeSpan &other)
Subtract-assign a TimeSpan.
bool operator>(const TimeSpan &other) const
Greater-than comparison.
static TimeSpan absDiff(std::chrono::system_clock::time_point t1, std::chrono::system_clock::time_point t2)
Compute the absolute difference between two chrono time points.
QString toDumpString() const
Format this TimeSpan as a verbose diagnostic string showing all internal fields.