|
KanoopCommonQt 2.1.1
Kanoop foundational Qt utility library
|
|
A time range defined by a start and end QDateTime. More...
#include <daterange.h>
Classes | |
| class | List |
| A sortable, consolidatable list of DateRange objects. More... | |
Public Member Functions | |
| DateRange () | |
| Default constructor — creates an invalid (empty) date range. | |
| DateRange (const QDateTime &startTime, const QDateTime &endTime) | |
| Construct a DateRange from explicit start and end times. | |
| DateRange (const QDateTime &startTime, const TimeSpan &duration) | |
| Construct a DateRange from a start time and duration. | |
| DateRange (const DateRange &other) | |
| Copy constructor. | |
| DateRange & | operator= (const DateRange &other) |
| Assignment operator. | |
| DateRange | operator+ (const TimeSpan &other) const |
| Shift both endpoints forward by a TimeSpan. | |
| DateRange | operator- (const TimeSpan &other) const |
| Shift both endpoints backward by a TimeSpan. | |
| void | operator+= (const TimeSpan &other) |
| Shift both endpoints forward by a TimeSpan in place. | |
| void | operator-= (const TimeSpan &other) |
| Shift both endpoints backward by a TimeSpan in place. | |
| bool | operator== (const DateRange &other) const |
| Equality comparison. | |
| bool | operator!= (const DateRange &other) const |
| Inequality comparison. | |
| QDateTime | startTime () const |
| Return the range start time. | |
| void | setStartTime (const QDateTime &value) |
| Set the range start time. | |
| QDateTime | endTime () const |
| Return the range end time. | |
| void | setEndTime (const QDateTime &value) |
| Set the range end time. | |
| TimeSpan | duration () const |
| Return the absolute duration of the range. | |
| QDateTime | midpoint () const |
| Return the midpoint of the range. | |
| bool | contains (const QDateTime &time) const |
| Test whether a timestamp falls within the range (inclusive). | |
| bool | contains (const DateRange &other) const |
| Test whether another DateRange is entirely contained within this one. | |
| bool | intersects (const DateRange &other) const |
| Test whether another DateRange is intersects with this one. | |
| DateRange | subRange (const DateRange &other) const |
| Return the intersection of this range with another. | |
| DateRange | merged (const DateRange &other) const |
| Return the union of this range and another. | |
| QString | toString () const |
| Format the range as a human-readable string. | |
| bool | isValid () const |
| Check whether both endpoints are valid QDateTime values. | |
Static Public Member Functions | |
| static DateRange | fromMidpoint (const QDateTime &midpoint, const TimeSpan &duration) |
| Create a DateRange centred on a midpoint with the given duration. | |
| static DateRange | merged (const DateRange &a, const DateRange &b) |
| Return the union of two ranges (static convenience overload). | |
A time range defined by a start and end QDateTime.
DateRange represents a contiguous span of time. It supports arithmetic with TimeSpan, overlap/containment queries, and consolidation of overlapping ranges via DateRange::List.
Represents a contiguous date/time range with start and end timestamps.
Definition at line 17 of file daterange.h.
|
inline |
Default constructor — creates an invalid (empty) date range.
Definition at line 21 of file daterange.h.
|
inline |
Construct a DateRange from explicit start and end times.
| startTime | Range begin timestamp |
| endTime | Range end timestamp |
Definition at line 28 of file daterange.h.
|
inline |
Construct a DateRange from a start time and duration.
| startTime | Range begin timestamp |
| duration | Length of the range |
Definition at line 36 of file daterange.h.
| DateRange::DateRange | ( | const DateRange & | other | ) |
Copy constructor.
| other | DateRange to copy. |
|
inline |
Test whether another DateRange is entirely contained within this one.
| other | Range to test |
Definition at line 134 of file daterange.h.
References contains(), endTime(), and startTime().
Referenced by contains().
|
inline |
Test whether a timestamp falls within the range (inclusive).
| time | Timestamp to test |
Definition at line 127 of file daterange.h.
|
inline |
Return the absolute duration of the range.
Definition at line 114 of file daterange.h.
References TimeSpan::absDiff().
|
inline |
Return the range end time.
Definition at line 102 of file daterange.h.
Referenced by DateRange::List::consolidated(), and contains().
| bool DateRange::intersects | ( | const DateRange & | other | ) | const |
Test whether another DateRange is intersects with this one.
| other | Range to test |
|
inline |
Check whether both endpoints are valid QDateTime values.
Definition at line 175 of file daterange.h.
Return the union of two ranges (static convenience overload).
| a | First range |
| b | Second range |
Definition at line 163 of file daterange.h.
References merged().
|
inline |
Return the midpoint of the range.
Definition at line 120 of file daterange.h.
| bool DateRange::operator!= | ( | const DateRange & | other | ) | const |
| void DateRange::operator+= | ( | const TimeSpan & | other | ) |
Shift both endpoints forward by a TimeSpan in place.
| other | Amount to add. |
| void DateRange::operator-= | ( | const TimeSpan & | other | ) |
Shift both endpoints backward by a TimeSpan in place.
| other | Amount to subtract. |
| bool DateRange::operator== | ( | const DateRange & | other | ) | const |
|
inline |
Set the range end time.
| value | New end QDateTime |
Definition at line 108 of file daterange.h.
|
inline |
Set the range start time.
| value | New start QDateTime |
Definition at line 96 of file daterange.h.
|
inline |
Return the range start time.
Definition at line 90 of file daterange.h.
Referenced by DateRange::List::consolidated(), and contains().
Return the intersection of this range with another.
| other | Range to intersect with |
| QString DateRange::toString | ( | ) | const |
Format the range as a human-readable string.